gpt4 book ai didi

java - 在 google maps api v2 中膨胀 fragment 异常

转载 作者:行者123 更新时间:2023-11-29 08:51:43 25 4
gpt4 key购买 nike

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment" />
</RelativeLayout>

这是 Activity 的布局文件,甚至添加了对播放服务项目的引用也输入了 api key ,但仍然显示错误。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.helloloc"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<permission
android:name="com.helloloc.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />

<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />

<uses-permission android:name="com.helloloc.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="key" />
<activity
android:name="com.helloloc.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application></manifest>

这是包含 api key 的 list 文件

日志猫异常是

03-18 13:02:06.579: W/asset(820): Copying FileAsset 0x74d4a850 (zip:/data/app/com.helloloc-1.apk:/resources.arsc) to buffer size 141712 to make it aligned.
03-18 13:02:06.919: W/dalvikvm(820): threadid=1: thread exiting with uncaught exception (group=0x416ebe18)
03-18 13:02:06.929: E/AndroidRuntime(820): FATAL EXCEPTION: main
03-18 13:02:06.929: E/AndroidRuntime(820): Process: com.helloloc, PID: 820
03-18 13:02:06.929: E/AndroidRuntime(820): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.helloloc/com.helloloc.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.ActivityThread.access$800(ActivityThread.java:156)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.os.Handler.dispatchMessage(Handler.java:102)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.os.Looper.loop(Looper.java:157)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.ActivityThread.main(ActivityThread.java:5872)
03-18 13:02:06.929: E/AndroidRuntime(820): at java.lang.reflect.Method.invokeNative(Native Method)
03-18 13:02:06.929: E/AndroidRuntime(820): at java.lang.reflect.Method.invoke(Method.java:515)
03-18 13:02:06.929: E/AndroidRuntime(820): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1069)
03-18 13:02:06.929: E/AndroidRuntime(820): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:885)
03-18 13:02:06.929: E/AndroidRuntime(820): at dalvik.system.NativeStart.main(Native Method)
03-18 13:02:06.929: E/AndroidRuntime(820): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
03-18 13:02:06.929: E/AndroidRuntime(820): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
03-18 13:02:06.929: E/AndroidRuntime(820): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:375)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.Activity.setContentView(Activity.java:1997)
03-18 13:02:06.929: E/AndroidRuntime(820): at com.helloloc.MainActivity.onCreate(MainActivity.java:21)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.Activity.performCreate(Activity.java:5312)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2552)
03-18 13:02:06.929: E/AndroidRuntime(820): ... 11 more
03-18 13:02:06.929: E/AndroidRuntime(820): Caused by: java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to ensure a correct behavior:
03-18 13:02:06.929: E/AndroidRuntime(820): <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
03-18 13:02:06.929: E/AndroidRuntime(820): at maps.e.ch.a(Unknown Source)
03-18 13:02:06.929: E/AndroidRuntime(820): at maps.e.ay.a(Unknown Source)
03-18 13:02:06.929: E/AndroidRuntime(820): at maps.e.ay.a(Unknown Source)
03-18 13:02:06.929: E/AndroidRuntime(820): at maps.e.al.a(Unknown Source)
03-18 13:02:06.929: E/AndroidRuntime(820): at maps.e.bg.a(Unknown Source)
03-18 13:02:06.929: E/AndroidRuntime(820): at maps.e.bf.a(Unknown Source)
03-18 13:02:06.929: E/AndroidRuntime(820): at eio.onTransact(SourceFile:107)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.os.Binder.transact(Binder.java:361)
03-18 13:02:06.929: E/AndroidRuntime(820): at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
03-18 13:02:06.929: E/AndroidRuntime(820): at com.google.android.gms.maps.MapFragment$a.onCreateView(Unknown Source)
03-18 13:02:06.929: E/AndroidRuntime(820): at com.google.android.gms.dynamic.a$4.b(Unknown Source)
03-18 13:02:06.929: E/AndroidRuntime(820): at com.google.android.gms.dynamic.a.a(Unknown Source)
03-18 13:02:06.929: E/AndroidRuntime(820): at com.google.android.gms.dynamic.a.onCreateView(Unknown Source)
03-18 13:02:06.929: E/AndroidRuntime(820): at com.google.android.gms.maps.MapFragment.onCreateView(Unknown Source)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.Fragment.performCreateView(Fragment.java:1777)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:875)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1084)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1201)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.app.Activity.onCreateView(Activity.java:4867)
03-18 13:02:06.929: E/AndroidRuntime(820): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
03-18 13:02:06.929: E/AndroidRuntime(820): ... 21 more
03-18 13:02:09.162: D/Process(820): killProcess, pid=820
03-18 13:02:09.162: D/Process(820): com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException:131 java.lang.ThreadGroup.uncaughtException:693 java.lang.ThreadGroup.uncaughtException:690

提前致谢

最佳答案

Caused by: java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to ensure a correct behavior: 03-18 13:02:06.929: E/AndroidRuntime(820): 03-18 13:02:06.929: E/AndroidRuntime(820): at maps.e.ch.a(Unknown Source)\

你需要添加这个

 <uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"/>

在 list 文件中

并且您需要以下内容作为应用程序标签的子项

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

关于java - 在 google maps api v2 中膨胀 fragment 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22485961/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com