android - 运行时错误

时间:2013-11-20 10:19:01

标签: android google-maps

这些是我在使用apiV2在android中尝试使用谷歌地图时遇到的错误。 请帮帮我。

11-20 15:44:39.835: E/AndroidRuntime(8002): FATAL EXCEPTION: main
11-20 15:44:39.835: E/AndroidRuntime(8002): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vogella.android.locationapi.maps/com.vogella.android.locationapi.maps.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.app.ActivityThread.access$600(ActivityThread.java:156)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.os.Looper.loop(Looper.java:153)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.app.ActivityThread.main(ActivityThread.java:5297)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at java.lang.reflect.Method.invokeNative(Native Method)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at java.lang.reflect.Method.invoke(Method.java:511)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at dalvik.system.NativeStart.main(Native Method)
11-20 15:44:39.835: E/AndroidRuntime(8002): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:274)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.app.Activity.setContentView(Activity.java:1881)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.vogella.android.locationapi.maps.MainActivity.onCreate(MainActivity.java:14)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.app.Activity.performCreate(Activity.java:5122)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
11-20 15:44:39.835: E/AndroidRuntime(8002):     ... 11 more
11-20 15:44:39.835: E/AndroidRuntime(8002): 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" />
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.google.android.gms.maps.internal.q.v(Unknown Source)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.google.android.gms.maps.internal.q.u(Unknown Source)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.google.android.gms.dynamic.a.a(Unknown Source)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
11-20 15:44:39.835: E/AndroidRuntime(8002):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
11-20 15:44:39.835: E/AndroidRuntime(8002):     ... 21 more

2 个答案:

答案 0 :(得分:0)

尝试在UI线程中运行您的地图代码。它可能不允许在主线程上运行

答案 1 :(得分:0)

从您发布的日志中检查:

  

您应用的AndroidManifest.xml中的元数据标记没有   正确的价值。预计4030500但是找到了0.你必须拥有   在元素中声明:

按照步骤google文档here

进行操作

或那个教程here。当然,谷歌地图api使用的网上文件太多了!