gpt4 book ai didi

java - Android SDK v9 上的 Google map V2 'the application has stopped unexpectedly'

转载 作者:行者123 更新时间:2023-12-02 06:55:56 25 4
gpt4 key购买 nike

我正在使用老板的手机来测试我们在 iOS 上开发的应用程序,然后转移到 Android。

我已关注this教程在手机上运行时出现标题中提到的错误。我听说 10 以下的 SDK 不支持 map ,是吗?非常不确定从这里该做什么。代码:

我有 3 个选项卡,我将它们作为 fragment 加载,有问题的 fragment 是:

注意:所有导入都是正确的

public class EventFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

// Inflate the layout for this fragment
View V = inflater.inflate(R.layout.event_layout, container, false);

return V;
}
}

在查看xml文件中:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/the_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"
map:cameraTilt="45"
map:cameraZoom="14"
/>

一切都在 list 中。当我删除它时,它运行良好。有解决这种问题的方法吗?

编辑:

Logcat 错误:

06-28 11:25:51.230: E/AndroidRuntime(3405): FATAL EXCEPTION: main
06-28 11:25:51.230: E/AndroidRuntime(3405): android.view.InflateException: Binary XML file line #1: Error inflating class fragment
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-28 11:25:51.230: E/AndroidRuntime(3405): at co.uk.dwdks.kendalmintfest.KendalInfoFragment.onCreateView(KendalInfoFragment.java:16)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.os.Handler.handleCallback(Handler.java:587)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.os.Handler.dispatchMessage(Handler.java:92)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.os.Looper.loop(Looper.java:143)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.app.ActivityThread.main(ActivityThread.java:4196)
06-28 11:25:51.230: E/AndroidRuntime(3405): at java.lang.reflect.Method.invokeNative(Native Method)
06-28 11:25:51.230: E/AndroidRuntime(3405): at java.lang.reflect.Method.invoke(Method.java:507)
06-28 11:25:51.230: E/AndroidRuntime(3405): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-28 11:25:51.230: E/AndroidRuntime(3405): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-28 11:25:51.230: E/AndroidRuntime(3405): at dalvik.system.NativeStart.main(Native Method)
06-28 11:25:51.230: E/AndroidRuntime(3405): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
06-28 11:25:51.230: E/AndroidRuntime(3405): ... 18 more
06-28 11:25:51.230: E/AndroidRuntime(3405): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment in loader dalvik.system.PathClassLoader[/data/app/co.uk.dwdks.kendalmintfest-2.apk]
06-28 11:25:51.230: E/AndroidRuntime(3405): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-28 11:25:51.230: E/AndroidRuntime(3405): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-28 11:25:51.230: E/AndroidRuntime(3405): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-28 11:25:51.230: E/AndroidRuntime(3405): at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
06-28 11:25:51.230: E/AndroidRuntime(3405): ... 21 more

最佳答案

我认为您需要实现 SupportFragment 并且 fragment 类需要为:class="com.google.android.gms.maps.SupportMapFragment"

关于java - Android SDK v9 上的 Google map V2 'the application has stopped unexpectedly',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17362255/

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