Google API密钥V2 RuntimeException

时间:2014-12-09 10:18:41

标签: android

我创建了一个示例Android应用程序,用于在我尝试运行时使用google api key v2访问谷歌地图时遇到此错误。

12-10 15:39:01.894: E/AndroidRuntime(483): FATAL EXCEPTION: main
12-10 15:39:01.894: E/AndroidRuntime(483): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.amutha.googleapiapp/com.amutha.googleapiapp.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.app.ActivityThread.access$1500(ActivityThread.java:122)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.os.Looper.loop(Looper.java:132)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.app.ActivityThread.main(ActivityThread.java:4025)
12-10 15:39:01.894: E/AndroidRuntime(483):  at java.lang.reflect.Method.invokeNative(Native Method)
12-10 15:39:01.894: E/AndroidRuntime(483):  at java.lang.reflect.Method.invoke(Method.java:491)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
12-10 15:39:01.894: E/AndroidRuntime(483):  at dalvik.system.NativeStart.main(Native Method)
12-10 15:39:01.894: E/AndroidRuntime(483): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:688)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:223)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.app.Activity.setContentView(Activity.java:1780)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.amutha.googleapiapp.MainActivity.onCreate(MainActivity.java:21)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
12-10 15:39:01.894: E/AndroidRuntime(483):  ... 11 more
12-10 15:39:01.894: E/AndroidRuntime(483): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 6171000 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-10 15:39:01.894: E/AndroidRuntime(483):  at com.google.android.gms.common.GooglePlayServicesUtil.E(Unknown Source)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.google.android.gms.maps.internal.u.T(Unknown Source)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.google.android.gms.maps.internal.u.S(Unknown Source)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.google.android.gms.maps.MapFragment$b.mA(Unknown Source)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.google.android.gms.dynamic.a.a(Unknown Source)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
12-10 15:39:01.894: E/AndroidRuntime(483):  at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.app.Activity.onCreateView(Activity.java:4140)
12-10 15:39:01.894: E/AndroidRuntime(483):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:664)

1 个答案:

答案 0 :(得分:2)

你的logcat清楚地说了

  

1 more 12-10 15:39:01.894:E / AndroidRuntime(483):引起:   java.lang.IllegalStateException:应用程序中的元数据标记   AndroidManifest.xml没有正确的值。预计6171000   但是找到了0.你必须在其中有以下声明   element:12-10 15:39:01.894:E / AndroidRuntime(483):at

<meta-data>

<application>标记中添加manifest.xml代码
  <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />