java - Application has stopped! GOOGLE API V2 - Map -
i have followed instruction on youtube create map/location application. first step show map stuck because of "unfortunately, mylocapp has stopped". codes followed. have been doing wrong?
manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android": package="tri.mylocapp" android:versioncode="1" android:versionname="1.0"> <uses-sdk android:minsdkversion="14" android:targetsdkversion="14" /> <permission android:name="tri.mylocapp.permission.maps_receive" android:protectionlevel="signature" /> <uses-permission android:name="tri.mylocapp.permission.maps_receive"/> <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"/> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <meta-data android:name="com.google.android.maps.v2.api_key" android:value="aizasydziavpm2kcj4qxnb01qxozqiextbxtabw"/> <activity android:name="tri.mylocapp.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> </manifest>
this layout 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" android:name="com.google.android.gms.maps.mapfragment"/>
this proguard-project.txt:
-keep class * extends java.util.listresourcebundle { protected object[][] getcontents(); }
this mainactivity.java:
package tri.mylocapp; 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); } }
logcat:
d/androidruntime(639): shutting down vm w/dalvikvm(639): threadid=1: thread exiting uncaught exception (group=0x409961f8) e/androidruntime(639): fatal exception: main e/androidruntime(639): java.lang.runtimeexception: unable start activity componentinfo{tri.mylocapp/tri.mylocapp.mainactivity}: android.view.inflateexception: binary xml file line #2: error inflating class fragment e/androidruntime(639): @ android.app.activitythread.performlaunchactivity(activitythread.java:1955) e/androidruntime(639): @ android.app.activitythread.handlelaunchactivity(activitythread.java:1980) e/androidruntime(639): @ android.app.activitythread.access$600(activitythread.java:122) e/androidruntime(639): @ android.app.activitythread$h.handlemessage(activitythread.java:1146) e/androidruntime(639): @ android.os.handler.dispatchmessage(handler.java:99) e/androidruntime(639): @ android.os.looper.loop(looper.java:137) e/androidruntime(639): @ android.app.activitythread.main(activitythread.java:4340) e/androidruntime(639): @ java.lang.reflect.method.invokenative(native method) e/androidruntime(639): @ java.lang.reflect.method.invoke(method.java:511) e/androidruntime(639): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:784) e/androidruntime(639): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:551) e/androidruntime(639): @ dalvik.system.nativestart.main(native method) e/androidruntime(639): caused by: android.view.inflateexception: binary xml file line #2: error inflating class fragment e/androidruntime(639): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:697) e/androidruntime(639): @ android.view.layoutinflater.inflate(layoutinflater.java:466) e/androidruntime(639): @ android.view.layoutinflater.inflate(layoutinflater.java:396) e/androidruntime(639): @ android.view.layoutinflater.inflate(layoutinflater.java:352) e/androidruntime(639): @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:251) e/androidruntime(639): @ android.app.activity.setcontentview(activity.java:1835) e/androidruntime(639): @ tri.mylocapp.mainactivity.oncreate(mainactivity.java:10) e/androidruntime(639): @ android.app.activity.performcreate(activity.java:4465) e/androidruntime(639): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1049) e/androidruntime(639): @ android.app.activitythread.performlaunchactivity(activitythread.java:1919) e/androidruntime(639): ... 11 more e/androidruntime(639): 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" /> e/androidruntime(639): @ com.google.android.gms.common.googleplayservicesutil.n(unknown source) e/androidruntime(639): @ com.google.android.gms.common.googleplayservicesutil.isgoogleplayservicesavailable(unknown source) e/androidruntime(639): @ com.google.android.gms.maps.internal.q.v(unknown source) e/androidruntime(639): @ com.google.android.gms.maps.internal.q.u(unknown source) e/androidruntime(639): @ com.google.android.gms.maps.mapsinitializer.initialize(unknown source) e/androidruntime(639): @ com.google.android.gms.maps.mapfragment$b.ex(unknown source) e/androidruntime(639): @ com.google.android.gms.maps.mapfragment$b.a(unknown source) e/androidruntime(639): @ com.google.android.gms.dynamic.a.a(unknown source) e/androidruntime(639): @ com.google.android.gms.dynamic.a.oninflate(unknown source) e/androidruntime(639): @ com.google.android.gms.maps.mapfragment.oninflate(unknown source) e/androidruntime(639): @ android.app.activity.oncreateview(activity.java:4242) e/androidruntime(639): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:673) e/androidruntime(639): ... 20 more i/process(639): sending signal. pid: 639 sig: 9
your logcat said
.818: e/androidruntime(639): 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-20 17:11:43.818:icesutil.isgoogleplayservicesavailable(unknown
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
build manifest.xml like:
....<application> .............. <meta-data android:name="com.google.android.maps.v2.api_key" android:value="aizasydrckdgxugl0ps4u2ptosiuci6ooxmz0ru" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> </application>
Comments
Post a Comment