android - LOG CAT Error on Google Maps API using basic tutorial -
i submitted similar question earlier on more advanced project, thought simplify things using maps api tutorial provided google try , replicate error getting, , same error! , bad, @ least know it's not project causing error.
now need figure out why getting error! new programming followed tutorial here verbatum:
https://developers.google.com/maps/documentation/android/start
here error getting:
03-24 20:47:03.244: e/androidruntime(6250): fatal exception: main 03-24 20:47:03.244: e/androidruntime(6250): java.lang.runtimeexception: unable start activity componentinfo{com.example.test/com.example.test.mainactivity}: android.view.inflateexception: binary xml file line #2: error inflating class fragment 03-24 20:47:03.244: e/androidruntime(6250): @ android.app.activitythread.performlaunchactivity(activitythread.java:2211) 03-24 20:47:03.244: e/androidruntime(6250): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2261) 03-24 20:47:03.244: e/androidruntime(6250): @ android.app.activitythread.access$600(activitythread.java:141) 03-24 20:47:03.244: e/androidruntime(6250): @ android.app.activitythread$h.handlemessage(activitythread.java:1256) 03-24 20:47:03.244: e/androidruntime(6250): @ android.os.handler.dispatchmessage(handler.java:99) 03-24 20:47:03.244: e/androidruntime(6250): @ android.os.looper.loop(looper.java:137) 03-24 20:47:03.244: e/androidruntime(6250): @ android.app.activitythread.main(activitythread.java:5103) 03-24 20:47:03.244: e/androidruntime(6250): @ java.lang.reflect.method.invokenative(native method) 03-24 20:47:03.244: e/androidruntime(6250): @ java.lang.reflect.method.invoke(method.java:525) 03-24 20:47:03.244: e/androidruntime(6250): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737) 03-24 20:47:03.244: e/androidruntime(6250): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 03-24 20:47:03.244: e/androidruntime(6250): @ dalvik.system.nativestart.main(native method) 03-24 20:47:03.244: e/androidruntime(6250): caused by: android.view.inflateexception: binary xml file line #2: error inflating class fragment 03-24 20:47:03.244: e/androidruntime(6250): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:713) 03-24 20:47:03.244: e/androidruntime(6250): @ android.view.layoutinflater.inflate(layoutinflater.java:469) 03-24 20:47:03.244: e/androidruntime(6250): @ android.view.layoutinflater.inflate(layoutinflater.java:397) 03-24 20:47:03.244: e/androidruntime(6250): @ android.view.layoutinflater.inflate(layoutinflater.java:353) 03-24 20:47:03.244: e/androidruntime(6250): @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:267) 03-24 20:47:03.244: e/androidruntime(6250): @ android.app.activity.setcontentview(activity.java:1895) 03-24 20:47:03.244: e/androidruntime(6250): @ com.example.test.mainactivity.oncreate(mainactivity.java:11) 03-24 20:47:03.244: e/androidruntime(6250): @ android.app.activity.performcreate(activity.java:5133) 03-24 20:47:03.244: e/androidruntime(6250): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) 03-24 20:47:03.244: e/androidruntime(6250): @ android.app.activitythread.performlaunchactivity(activitythread.java:2175) 03-24 20:47:03.244: e/androidruntime(6250): ... 11 more 03-24 20:47:03.244: e/androidruntime(6250): caused by: java.lang.illegalstateexception: meta-data tag in app's androidmanifest.xml not have right value. expected 4242000 found 0. must have following declaration within <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> 03-24 20:47:03.244: e/androidruntime(6250): @ com.google.android.gms.common.googleplayservicesutil.n(unknown source) 03-24 20:47:03.244: e/androidruntime(6250): @ com.google.android.gms.common.googleplayservicesutil.isgoogleplayservicesavailable(unknown source) 03-24 20:47:03.244: e/androidruntime(6250): @ com.google.android.gms.maps.internal.q.v(unknown source) 03-24 20:47:03.244: e/androidruntime(6250): @ com.google.android.gms.maps.internal.q.u(unknown source) 03-24 20:47:03.244: e/androidruntime(6250): @ com.google.android.gms.maps.mapsinitializer.initialize(unknown source) 03-24 20:47:03.244: e/androidruntime(6250): @ com.google.android.gms.maps.mapfragment$b.ex(unknown source) 03-24 20:47:03.244: e/androidruntime(6250): @ com.google.android.gms.maps.mapfragment$b.a(unknown source) 03-24 20:47:03.244: e/androidruntime(6250): @ com.google.android.gms.dynamic.a.a(unknown source) 03-24 20:47:03.244: e/androidruntime(6250): @ com.google.android.gms.dynamic.a.oninflate(unknown source) 03-24 20:47:03.244: e/androidruntime(6250): @ com.google.android.gms.maps.mapfragment.oninflate(unknown source) 03-24 20:47:03.244: e/androidruntime(6250): @ android.app.activity.oncreateview(activity.java:4745) 03-24 20:47:03.244: e/androidruntime(6250): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:689) 03-24 20:47:03.244: e/androidruntime(6250): ... 20 more
here simple mainactivity.java
package com.example.test; import android.app.activity; import android.os.bundle; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } }
here simple activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.supportmapfragment" android:name="com.example.test.mainactivity"/>
here manifest:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.test" android:versioncode="1" android:versionname="1.0" > <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.access_network_state"/> <uses-permission android:name="android.permission.write_external_storage"/> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices"/> <!-- following 2 permissions not required use google maps android api v2, recommended. --> <uses-permission android:name="android.permission.access_coarse_location"/> <uses-permission android:name="android.permission.access_fine_location"/> <uses-feature android:glesversion="0x00020000" android:required="true"/> <uses-sdk android:minsdkversion="8" android:targetsdkversion="19" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.example.test.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="hidden"/> </application> </manifest>
the thing can think of manifest file improperly set up. followed instructions , eclipse didn't give me error on it. in arms here trying figure out. appreciated.
your logcat said
caused by: java.lang.illegalstateexception: meta-data tag in app's androidmanifest.xml not have right value. expected 4242000 found 0. must have following declaration within <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> 03-24 20:47:03.244: e/androidruntime(6250): @ com.google.android.gms.common.googleplayservicesutil.n(unknown source)
add google play services version app's manifest
edit application's androidmanifest.xml file, , add following declaration within element. embeds version of google play services app compiled with.
you need add <meta-data>
under <application>
tag androidmanifest.xml
....<application> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> </application>
this because latest google play services requires version name, mentioned using <meta-data .. />
inside androidmanifest.xml
....<application> .............. <meta-data android:name="com.google.android.maps.v2.api_key" android:value="key" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> </application>
also extends activity
fragmentactivity
mainactivity extends fragmentactivity
Comments
Post a Comment