0

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

我已经按照这个教程在手机上运行时给出了标题中提到的错误。我读过 10 以下的 SDK 不支持地图,对吗?很不确定从这里做什么。代码:

我有 3 个选项卡作为片段加载,有问题的片段是:

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

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"
    />

一切都在清单中。当我删除它运行良好。这种事情有解决办法吗?

编辑:

日志错误:

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
4

2 回答 2

2

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

于 2013-06-28T10:38:10.453 回答
0

地图工作(公平)从 API8 开始。但是您需要将您的应用程序与 链接google-play-servces_lib,这很可能在您的情况下没有完成。还要确保您在 Manifest 中设置了所有权限。最后,查看官方文档:https ://developers.google.com/maps/documentation/android/

于 2013-06-28T10:35:09.563 回答