Google Maps Android API V2 problems -


i'm trying put working example of google maps android api v2. have found 4 tutorials describe how (dj-android, vogella, 2 tutorials official docs) , none of them work. have found dozen posts, one, many other developers, same problem: "binary xml file line #x error inflating class". on stackoverflow, none of dozen posts have single accepted answer. know of no working examples of api anywhere on internet.

the contents of project pasted below. think have has been recommended various posts but, many others, i'm getting inflation run time error.

this actual project taken vogella tutorial wouldn't compile. applied fixes other posts of same problem.

can tell me how make work? know of working example anywhere? thanks, gary

manifest file...

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.mapdemo"     android:versioncode="1"     android:versionname="1.0" >      <uses-sdk         android:minsdkversion="8"         android:targetsdkversion="17" />          <permission         android:name="com.vogella.android.locationapi.maps.permission.maps_receive"         android:protectionlevel="signature" />      <uses-feature         android:glesversion="0x00020000"         android:required="true" />      <uses-permission android:name="com.vogella.android.locationapi.maps.permission.maps_receive" />     <uses-permission android:name="android.permission.internet" />     <uses-permission android:name="android.permission.write_external_storage" />     <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" />     <uses-permission android:name="android.permission.access_coarse_location" />     <uses-permission android:name="android.permission.access_fine_location" />      <application         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/apptheme" >         <activity             android:name="com.example.mapdemo.mainactivity"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="android.intent.action.main" />                  <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity>      </application>       <meta-data             android:name="com.google.android.maps.v2.api_key"             android:value="i have valid v2 key here" /> </manifest> 

i have google play services library project in workspace . . . i copied library project workspace

my main layout xml file . . .

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity" >  <fragment     android:id="@+id/map"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:name="com.example.mapdemo.mainactivity"     class="com.google.android.gms.maps.supportmapfragment" />  </relativelayout>  

the mainactivity.java file . . . (wish code paste worked on forum)

package com.example.mapdemo;  import android.app.activity; import android.os.bundle; import android.view.menu;  import android.support.v4.app.fragmentactivity;   import com.google.android.gms.maps.supportmapfragment;    import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.mapfragment; import com.google.android.gms.maps.model.bitmapdescriptorfactory; import com.google.android.gms.maps.model.latlng; import com.google.android.gms.maps.model.marker; import com.google.android.gms.maps.model.markeroptions;  public class mainactivity extends android.support.v4.app.fragmentactivity {   static final latlng hamburg = new latlng(53.558, 9.927);   static final latlng kiel = new latlng(53.551, 9.993);   private googlemap map;    @override   protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     map = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map))         .getmap();     marker hamburg = map.addmarker(new markeroptions().position(hamburg)         .title("hamburg"));     marker kiel = map.addmarker(new markeroptions()         .position(kiel)         .title("kiel")         .snippet("kiel cool")         .icon(bitmapdescriptorfactory             .fromresource(r.drawable.ic_launcher)));      // move camera instantly hamburg zoom of 15.     map.movecamera(cameraupdatefactory.newlatlngzoom(hamburg, 15));      // zoom in, animating camera.     map.animatecamera(cameraupdatefactory.zoomto(10), 2000, null);   }    @override   public boolean oncreateoptionsmenu(menu menu) {      return true;   }  }  

the logcat... (is there secret pasting stuff?)

08-12 13:00:52.380: w/dalvikvm(8118): vfy: unable resolve instance field 28 08-12 13:00:52.550: w/dalvikvm(8118): unable resolve superclass of lmaps/p/w; (734) 08-12 13:00:52.550: w/dalvikvm(8118): link of class 'lmaps/p/w;' failed 08-12 13:00:52.550: w/dalvikvm(8118): unable resolve superclass of lmaps/ap/as; (6056) 08-12 13:00:52.550: w/dalvikvm(8118): link of class 'lmaps/ap/as;' failed 08-12 13:00:52.550: w/dalvikvm(8118): unable resolve superclass of lmaps/af/k; (5085) 08-12 13:00:52.550: w/dalvikvm(8118): link of class 'lmaps/af/k;' failed 08-12 13:00:52.550: e/dalvikvm(8118): not find class 'maps.af.k', referenced method maps.ag.an.a 08-12 13:00:52.550: w/dalvikvm(8118): vfy: unable resolve new-instance 4928 (lmaps/af/k;) in lmaps/ag/an; 08-12 13:00:52.681: w/dalvikvm(8118): threadid=1: thread exiting uncaught exception (group=0x40017560) 08-12 13:00:52.691: e/androidruntime(8118): fatal exception: main 08-12 13:00:52.691: e/androidruntime(8118): java.lang.runtimeexception: unable start activity componentinfo{com.example.mapdemo/com.example.mapdemo.mainactivity}: android.view.inflateexception: binary xml file line #7: error inflating class fragment 08-12 13:00:52.691: e/androidruntime(8118):     @ android.app.activitythread.performlaunchactivity(activitythread.java:1647) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:1663) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.app.activitythread.access$1500(activitythread.java:117) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.app.activitythread$h.handlemessage(activitythread.java:931) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.os.handler.dispatchmessage(handler.java:99) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.os.looper.loop(looper.java:130) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.app.activitythread.main(activitythread.java:3683) 08-12 13:00:52.691: e/androidruntime(8118):     @ java.lang.reflect.method.invokenative(native method) 08-12 13:00:52.691: e/androidruntime(8118):     @ java.lang.reflect.method.invoke(method.java:507) 08-12 13:00:52.691: e/androidruntime(8118):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:875) 08-12 13:00:52.691: e/androidruntime(8118):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:633) 08-12 13:00:52.691: e/androidruntime(8118):     @ dalvik.system.nativestart.main(native method) 08-12 13:00:52.691: e/androidruntime(8118): caused by: android.view.inflateexception: binary xml file line #7: error inflating class fragment 08-12 13:00:52.691: e/androidruntime(8118):     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:587) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.view.layoutinflater.rinflate(layoutinflater.java:623) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.view.layoutinflater.inflate(layoutinflater.java:408) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.view.layoutinflater.inflate(layoutinflater.java:320) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.view.layoutinflater.inflate(layoutinflater.java:276) 08-12 13:00:52.691: e/androidruntime(8118):     @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:212) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.app.activity.setcontentview(activity.java:1657) 08-12 13:00:52.691: e/androidruntime(8118):     @ com.example.mapdemo.mainactivity.oncreate(mainactivity.java:26) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.app.activitythread.performlaunchactivity(activitythread.java:1611) 08-12 13:00:52.691: e/androidruntime(8118):     ... 11 more 08-12 13:00:52.691: e/androidruntime(8118): caused by: java.lang.runtimeexception: api key not found.  check <meta-data android:name="com.google.android.maps.v2.api_key" android:value="your api key"/> in <application> element of androidmanifest.xml 08-12 13:00:52.691: e/androidruntime(8118):     @ maps.ag.bb.a(unknown source) 08-12 13:00:52.691: e/androidruntime(8118):     @ maps.ag.bb.a(unknown source) 08-12 13:00:52.691: e/androidruntime(8118):     @ maps.ag.an.a(unknown source) 08-12 13:00:52.691: e/androidruntime(8118):     @ maps.ag.bi.a(unknown source) 08-12 13:00:52.691: e/androidruntime(8118):     @ maps.ag.bh.a(unknown source) 08-12 13:00:52.691: e/androidruntime(8118):     @ blf.ontransact(sourcefile:107) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.os.binder.transact(binder.java:279) 08-12 13:00:52.691: e/androidruntime(8118):     @ com.google.android.gms.maps.internal.imapfragmentdelegate$a$a.oncreateview(unknown source) 08-12 13:00:52.691: e/androidruntime(8118):     @ com.google.android.gms.maps.supportmapfragment$a.oncreateview(unknown source) 08-12 13:00:52.691: e/androidruntime(8118):     @ com.google.android.gms.internal.bh$4.b(unknown source) 08-12 13:00:52.691: e/androidruntime(8118):     @ com.google.android.gms.internal.bh.a(unknown source) 08-12 13:00:52.691: e/androidruntime(8118):     @ com.google.android.gms.internal.bh.oncreateview(unknown source) 08-12 13:00:52.691: e/androidruntime(8118):     @ com.google.android.gms.maps.supportmapfragment.oncreateview(unknown source) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.support.v4.app.fragment.performcreateview(fragment.java:1460) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:884) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1066) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.support.v4.app.fragmentmanagerimpl.addfragment(fragmentmanager.java:1168) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.support.v4.app.fragmentactivity.oncreateview(fragmentactivity.java:280) 08-12 13:00:52.691: e/androidruntime(8118):     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:563) 08-12 13:00:52.691: e/androidruntime(8118):     ... 20 more 

i know of no working examples of api anywhere on internet.

here 13 sample projects demonstrating use of various aspects of maps v2.

and i'm reasonably some, if not all, of samples started work.

can tell me how make work?

with regards to:

08-12 13:00:52.691: e/androidruntime(8118): caused by: java.lang.runtimeexception: api key not found 

you getting because <meta-data> element in wrong place. needs child of <application> element:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.commonsware.android.mapsv2.basic"     android:versioncode="1"     android:versionname="1.0">      <uses-sdk         android:minsdkversion="8"         android:targetsdkversion="16"/>      <uses-permission android:name="android.permission.internet"/>     <uses-permission android:name="android.permission.write_external_storage"/>     <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices"/>     <uses-permission android:name="android.permission.access_network_state"/>      <uses-feature         android:glesversion="0x00020000"         android:required="false"/>      <application         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/theme.sherlock.light.darkactionbar">         <activity             android:name="mainactivity"             android:label="@string/app_name">             <intent-filter>                 <action android:name="android.intent.action.main"/>                  <category android:name="android.intent.category.launcher"/>             </intent-filter>         </activity>          <meta-data             android:name="com.google.android.maps.v2.api_key"             android:value="aizasyc4iyt46cb00idkgcy5emaxk5ucoqx2oy8"/>          <activity android:name="legalnoticesactivity">         </activity>     </application>  </manifest> 

lars vogel's maps v2 tutorial, example, has in right place.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -