Question

I have been working with this tutorial [http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/]

Its GPS Map Location App that gets your location, or nearby location. I and many others have tested this and there seems to be an error as the app just crashes. I have changed the SHA1 Fingerprint and Google API Key. There are no errors in the code, i have imported the google play store.

Does anyone have any ideas on this, I have looked at the comments on the website and allot of users are having the same problem. Here is LogCat:

03-26 03:43:53.835: W/dalvikvm(15048): threadid=1: thread exiting with uncaught exception (group=0x42014700)
03-26 03:43:53.845: E/AndroidRuntime(15048): FATAL EXCEPTION: main
03-26 03:43:53.845: E/AndroidRuntime(15048): java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.googlemapsv2/info.androidhive.googlemapsv2.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.app.ActivityThread.access$700(ActivityThread.java:159)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.os.Looper.loop(Looper.java:176)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.app.ActivityThread.main(ActivityThread.java:5419)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at java.lang.reflect.Method.invokeNative(Native Method)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at java.lang.reflect.Method.invoke(Method.java:525)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at dalvik.system.NativeStart.main(Native Method)
03-26 03:43:53.845: E/AndroidRuntime(15048): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.app.Activity.setContentView(Activity.java:1956)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at info.androidhive.googlemapsv2.MainActivity.onCreate(MainActivity.java:24)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.app.Activity.performCreate(Activity.java:5372)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
03-26 03:43:53.845: E/AndroidRuntime(15048):    ... 11 more
03-26 03:43:53.845: E/AndroidRuntime(15048): Caused by: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.google.android.gms.maps.internal.q.B(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.google.android.gms.maps.internal.q.A(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.google.android.gms.maps.MapFragment$b.gW(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.google.android.gms.dynamic.a.a(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.app.Activity.onCreateView(Activity.java:4965)
03-26 03:43:53.845: E/AndroidRuntime(15048):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
03-26 03:43:53.845: E/AndroidRuntime(15048):    ... 21 more
Was it helpful?

Solution

Your logcat clearly said:

 Caused by: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
 03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
 03-26 03:43:53.845: E/AndroidRuntime(15048):    at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAv

Add the Google Play services version to your app's manifest

Edit your application's AndroidManifest.xml file, and add the following declaration within the element. This embeds the version of Google Play services that the app was compiled with.

You just need to add <meta-data> under <application> tag into your AndroidManifest.xml

....<application>
<meta-data android:name="com.google.android.gms.version"  
 android:value="@integer/google_play_services_version" />
</application>

This is because latest google play services requires a version name, which is to be mentioned using <meta-data .. /> inside AndroidManifest.xml

build your manifest.xml like:

....<application>
  ..............
  <meta-data
  android:name="com.google.android.maps.v2.API_KEY"
  android:value="APIKEY" />

  <meta-data android:name="com.google.android.gms.version"  
  android:value="@integer/google_play_services_version" />

   </application>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top