在android google map v2没有启动activity.How如何解决?

时间:2013-12-21 07:06:24

标签: android

12-21 02:04:02.430: E/AndroidRuntime(1690): FATAL EXCEPTION: main
12-21 02:04:02.430: E/AndroidRuntime(1690): Process: com.example.main, PID: 1690
12-21 02:04:02.430: E/AndroidRuntime(1690): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.main/com.example.main.ShowRouteMap}: android.view.InflateException: Binary XML file line #66: Error inflating class fragment
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.app.ActivityThread.access$700(ActivityThread.java:135)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.os.Handler.dispatchMessage(Handler.java:102)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.os.Looper.loop(Looper.java:137)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.app.ActivityThread.main(ActivityThread.java:4998)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at java.lang.reflect.Method.invokeNative(Native Method)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at java.lang.reflect.Method.invoke(Method.java:515)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at dalvik.system.NativeStart.main(Native Method)
12-21 02:04:02.430: E/AndroidRuntime(1690): Caused by: android.view.InflateException: Binary XML file line #66: Error inflating class fragment
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.app.Activity.setContentView(Activity.java:1928)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.example.main.ShowRouteMap.onCreate(ShowRouteMap.java:19)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.app.Activity.performCreate(Activity.java:5243)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
12-21 02:04:02.430: E/AndroidRuntime(1690):     ... 11 more
12-21 02:04:02.430: E/AndroidRuntime(1690): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4030500 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" />
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.google.android.gms.maps.internal.q.v(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.google.android.gms.maps.internal.q.u(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.google.android.gms.dynamic.a.a(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
12-21 02:04:02.430: E/AndroidRuntime(1690):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-21 02:04:02.430: E/AndroidRuntime(1690):     ... 21 more

2 个答案:

答案 0 :(得分:1)

你可以看到你的日志行

12-21 02:04:02.430: E/AndroidRuntime(1690): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4030500 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" />

解决方案

将它放在应用程序标记

下的AndroidManifest.xml中
<meta-data
            android:name="com.google.android.gms.version"
            android:value="4030500" />

答案 1 :(得分:1)

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

将其放在清单的末尾,放在Map API密钥元数据标记之后。由于您在onCreate方法中检查了GPlayServices的可用性