我刚开始使用Android谷歌地图。我下载this示例并更改API密钥并运行它,但它会出错。这是log cat输出: 谢谢你的帮助。
02-23 18:02:29.404: E/AndroidRuntime(1696): FATAL EXCEPTION: main
02-23 18:02:29.404: E/AndroidRuntime(1696): Process: info.androidhive.googlemapsv2, PID: 1696
02-23 18:02:29.404: E/AndroidRuntime(1696): 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
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.app.ActivityThread.access$800(ActivityThread.java:135)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.os.Handler.dispatchMessage(Handler.java:102)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.os.Looper.loop(Looper.java:136)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.app.ActivityThread.main(ActivityThread.java:5001)
02-23 18:02:29.404: E/AndroidRuntime(1696): at java.lang.reflect.Method.invokeNative(Native Method)
02-23 18:02:29.404: E/AndroidRuntime(1696): at java.lang.reflect.Method.invoke(Method.java:515)
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
02-23 18:02:29.404: E/AndroidRuntime(1696): at dalvik.system.NativeStart.main(Native Method)
02-23 18:02:29.404: E/AndroidRuntime(1696): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.app.Activity.setContentView(Activity.java:1929)
02-23 18:02:29.404: E/AndroidRuntime(1696): at info.androidhive.googlemapsv2.MainActivity.onCreate(MainActivity.java:24)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.app.Activity.performCreate(Activity.java:5231)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
02-23 18:02:29.404: E/AndroidRuntime(1696): ... 11 more
02-23 18:02:29.404: E/AndroidRuntime(1696): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 5077000 but found 0. 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" />
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.google.android.gms.common.GooglePlayServicesUtil.x(Unknown Source)
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.google.android.gms.maps.internal.u.F(Unknown Source)
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.google.android.gms.maps.internal.u.E(Unknown Source)
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.google.android.gms.maps.MapFragment$b.ju(Unknown Source)
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.google.android.gms.dynamic.a.a(Unknown Source)
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
02-23 18:02:29.404: E/AndroidRuntime(1696): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.app.Activity.onCreateView(Activity.java:4785)
02-23 18:02:29.404: E/AndroidRuntime(1696): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
答案 0 :(得分:1)
如错误所示,您的AndroidManifest.xml必须包含:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />