本文介绍了GoogleAPI关键V2的RuntimeException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个样本Android应用程序访问的GoogleMap与googleapi关键V2,当我尝试运行我得到这个错误。
12-10 15:39:01.894:E / AndroidRuntime(483):致命异常:主要
12-10 15:39:01.894:E / AndroidRuntime(483):java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.amutha.googleapiapp / com.amutha.googleapiapp.MainActivity}:android.view.InflateException:二进制XML文件,6号线:错误充气类片段
12-10 15:39:01.894:E / AndroidRuntime(483):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.app.ActivityThread.access $ 1500(ActivityThread.java:122)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1002)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.os.Handler.dispatchMessage(Handler.java:99)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.os.Looper.loop(Looper.java:132)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.app.ActivityThread.main(ActivityThread.java:4025)
12-10 15:39:01.894:E / AndroidRuntime(483):在java.lang.reflect.Method.invokeNative(本机方法)
12-10 15:39:01.894:E / AndroidRuntime(483):在java.lang.reflect.Method.invoke(Method.java:491)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:841)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
12-10 15:39:01.894:E / AndroidRuntime(483):在dalvik.system.NativeStart.main(本机方法)
12-10 15:39:01.894:E / AndroidRuntime(483):android.view.InflateException:二进制XML文件,6号线:错误充气类片段产生的原因
12-10 15:39:01.894:E / AndroidRuntime(483):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:688)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.view.LayoutInflater.inflate(LayoutInflater.java:479)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.view.LayoutInflater.inflate(LayoutInflater.java:391)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.view.LayoutInflater.inflate(LayoutInflater.java:347)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:223)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.app.Activity.setContentView(Activity.java:1780)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.amutha.googleapiapp.MainActivity.onCreate(MainActivity.java:21)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
12-10 15:39:01.894:E / AndroidRuntime(483):11 ...更多
12-10 15:39:01.894:E / AndroidRuntime(483):java.lang.IllegalStateException:在您的应用程序的AndroidManifest.xml中的元数据标签没有正确的价值所致。预计6171000但发现0。你必须在&lt中的以下声明;用途>元:其中,元数据的android:NAME =com.google.android.gms.version机器人:值=@整数/ google_play_services_version/>
12-10 15:39:01.894:E / AndroidRuntime(483):在com.google.android.gms.common.GooglePlayServicesUtil.E(来源不明)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(来源不明)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.google.android.gms.maps.internal.uT(来源不明)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.google.android.gms.maps.internal.uS(来源不明)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.google.android.gms.maps.MapsInitializer.initialize(来源不明)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.google.android.gms.maps.MapFragment $ b.mA(来源不明)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.google.android.gms.maps.MapFragment $ BA(来源不明)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.google.android.gms.dynamic.aa(来源不明)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.google.android.gms.dynamic.a.onInflate(来源不明)
12-10 15:39:01.894:E / AndroidRuntime(483):在com.google.android.gms.maps.MapFragment.onInflate(来源不明)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.app.Activity.onCreateView(Activity.java:4140)
12-10 15:39:01.894:E / AndroidRuntime(483):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:664)
解决方案
您的logcat说清楚
添加<元数据>
的标记<应用>
在的manifest.xml
<元数据
机器人:名称=com.google.android.gms.version
机器人:值=@整数/ google_play_services_version/>
I have created one sample android application for accessing googlemap with googleapi key v2 when i try to run i was getting this error.
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)
解决方案
Your logcat clearly said
add <meta-data>
tag in <application>
tag in your manifest.xml
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
这篇关于GoogleAPI关键V2的RuntimeException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!