gpt4 book ai didi

android google map v.2 : android. view.InflateException: Binary XML file line #739: 错误膨胀类 fragment

转载 作者:太空狗 更新时间:2023-10-29 16:39:46 24 4
gpt4 key购买 nike

我在 stackoverflow 中找到了类似的主题,但对我没有帮助。我想显示 map ,但是当我运行它时,它会强制关闭。以下是代码:

map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();

这是我的布局:

   <fragment
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_margin="20dp"
class="com.google.android.gms.maps.MapFragment" />

这是我的 list :

   <meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY_API_KEY" />


</application>

这是我的日志:

11-13 16:03:10.652: E/AndroidRuntime(32202): FATAL EXCEPTION: main
11-13 16:03:10.652: E/AndroidRuntime(32202): java.lang.RuntimeException: Unable to start activity ComponentInfo{id.go.kpp.aplikasipupi/id.go.kpp.aplikasipupi.kartu}: android.view.InflateException: Binary XML file line #739: Error inflating class fragment
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.os.Handler.dispatchMessage(Handler.java:99)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.os.Looper.loop(Looper.java:137)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.app.ActivityThread.main(ActivityThread.java:4895)
11-13 16:03:10.652: E/AndroidRuntime(32202): at java.lang.reflect.Method.invokeNative(Native Method)
11-13 16:03:10.652: E/AndroidRuntime(32202): at java.lang.reflect.Method.invoke(Method.java:511)
11-13 16:03:10.652: E/AndroidRuntime(32202): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
11-13 16:03:10.652: E/AndroidRuntime(32202): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
11-13 16:03:10.652: E/AndroidRuntime(32202): at dalvik.system.NativeStart.main(Native Method)
11-13 16:03:10.652: E/AndroidRuntime(32202): Caused by: android.view.InflateException: Binary XML file line #739: Error inflating class fragment
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-13 16:03:10.652: E/AndroidRuntime(32202): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:306)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.app.Activity.setContentView(Activity.java:1912)
11-13 16:03:10.652: E/AndroidRuntime(32202): at id.go.kpp.aplikasipupi.kartu.onCreate(kartu.java:100)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.app.Activity.performCreate(Activity.java:5163)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
11-13 16:03:10.652: E/AndroidRuntime(32202): ... 11 more
11-13 16:03:10.652: E/AndroidRuntime(32202): 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-13 16:03:10.652: E/AndroidRuntime(32202): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
11-13 16:03:10.652: E/AndroidRuntime(32202): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-13 16:03:10.652: E/AndroidRuntime(32202): at com.google.android.gms.maps.internal.q.v(Unknown Source)
11-13 16:03:10.652: E/AndroidRuntime(32202): at com.google.android.gms.maps.internal.q.u(Unknown Source)
11-13 16:03:10.652: E/AndroidRuntime(32202): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-13 16:03:10.652: E/AndroidRuntime(32202): at com.google.android.gms.maps.MapFragment$b.cE(Unknown Source)
11-13 16:03:10.652: E/AndroidRuntime(32202): at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
11-13 16:03:10.652: E/AndroidRuntime(32202): at com.google.android.gms.dynamic.a.a(Unknown Source)
11-13 16:03:10.652: E/AndroidRuntime(32202): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-13 16:03:10.652: E/AndroidRuntime(32202): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.app.Activity.onCreateView(Activity.java:4813)
11-13 16:03:10.652: E/AndroidRuntime(32202): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
11-13 16:03:10.652: E/AndroidRuntime(32202): ... 24 more

我不知道为什么它仍然错误,我希望有人能帮助我解决我的问题。

最佳答案

logcat 清晰

您需要将以下内容添加到 list 文件

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

https://developers.google.com/maps/documentation/android/start#add_the_google_play_services_version_to_your_apps_manifest

编辑应用程序的 AndroidManifest.xml 文件,并在 <application> 中添加以下声明元素。这嵌入了编译该应用的 Google Play 服务版本。

关于android google map v.2 : android. view.InflateException: Binary XML file line #739: 错误膨胀类 fragment ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19949420/

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