Android谷歌地图v2错误

时间:2014-02-18 19:28:42

标签: android google-maps android-maps-v2

我正在关注本教程: http://www.tutos-android.com/introduction-a-google-map-v2

这是源代码: http://www.tutos-android.com/wp-content/uploads/2013/03/GmapV2.zip

我得到了这个错误:

02-18 18:51:05.699: E/Trace(774): error opening trace file: No such file or directory (2)
02-18 18:51:06.818: E/AndroidRuntime(774): FATAL EXCEPTION: main
02-18 18:51:06.818: E/AndroidRuntime(774): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tutos.android.gmapv2/com.tutos.android.gmapv2.MyMapActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.os.Looper.loop(Looper.java:137)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.app.ActivityThread.main(ActivityThread.java:4745)
02-18 18:51:06.818: E/AndroidRuntime(774):  at java.lang.reflect.Method.invokeNative(Native Method)
02-18 18:51:06.818: E/AndroidRuntime(774):  at java.lang.reflect.Method.invoke(Method.java:511)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-18 18:51:06.818: E/AndroidRuntime(774):  at dalvik.system.NativeStart.main(Native Method)
02-18 18:51:06.818: E/AndroidRuntime(774): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.app.Activity.setContentView(Activity.java:1867)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.tutos.android.gmapv2.MyMapActivity.onCreate(MyMapActivity.java:17)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.app.Activity.performCreate(Activity.java:5008)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
02-18 18:51:06.818: E/AndroidRuntime(774):  ... 11 more
02-18 18:51:06.818: E/AndroidRuntime(774): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4242000 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-18 18:51:06.818: E/AndroidRuntime(774):  at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.google.android.gms.maps.internal.q.v(Unknown Source)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.google.android.gms.maps.internal.q.u(Unknown Source)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.google.android.gms.maps.SupportMapFragment$b.ex(Unknown Source)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.google.android.gms.dynamic.a.a(Unknown Source)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
02-18 18:51:06.818: E/AndroidRuntime(774):  at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
02-18 18:51:06.818: E/AndroidRuntime(774):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
02-18 18:51:06.818: E/AndroidRuntime(774):  ... 20 more
02-18 20:22:23.061: E/AndroidRuntime(1035): FATAL EXCEPTION: main
02-18 20:22:23.061: E/AndroidRuntime(1035): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tutos.android.gmapv2/com.tutos.android.gmapv2.MyMapActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.os.Looper.loop(Looper.java:137)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.app.ActivityThread.main(ActivityThread.java:4745)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at java.lang.reflect.Method.invokeNative(Native Method)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at java.lang.reflect.Method.invoke(Method.java:511)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at dalvik.system.NativeStart.main(Native Method)
02-18 20:22:23.061: E/AndroidRuntime(1035): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.app.Activity.setContentView(Activity.java:1867)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.tutos.android.gmapv2.MyMapActivity.onCreate(MyMapActivity.java:17)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.app.Activity.performCreate(Activity.java:5008)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
02-18 20:22:23.061: E/AndroidRuntime(1035):     ... 11 more
02-18 20:22:23.061: E/AndroidRuntime(1035): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4242000 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-18 20:22:23.061: E/AndroidRuntime(1035):     at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.google.android.gms.maps.internal.q.v(Unknown Source)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.google.android.gms.maps.internal.q.u(Unknown Source)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.google.android.gms.maps.SupportMapFragment$b.ex(Unknown Source)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.google.android.gms.dynamic.a.a(Unknown Source)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
02-18 20:22:23.061: E/AndroidRuntime(1035):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
02-18 20:22:23.061: E/AndroidRuntime(1035):     ... 20 more

请问任何解决方案?

1 个答案:

答案 0 :(得分:10)

你的日志猫自己清楚地告诉

  

引起:java.lang.IllegalStateException:应用程序的AndroidManifest.xml中的元数据标记没有正确的值。预期4242000但找到0.您必须在元素中包含以下声明:

所以你需要在应用程序元素的Android清单中添加这些行:

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