地图视图在较低版本的Android操作系统中崩溃

时间:2013-11-20 09:51:52

标签: android google-maps

我已按照https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2中的步骤在android中实现Map。

我已经在三星Note II(版本4.1.2),三星10.1“Tab(版本4.0)中测试过,我正确地获得了地图但是当我在三星Galaxy Ace(版本2.3.6)中测试时,它正在崩溃我得到了崩溃日志

11-20 15:13:39.759: E/AndroidRuntime(2067): FATAL EXCEPTION: main
11-20 15:13:39.759: E/AndroidRuntime(2067): java.lang.RuntimeException: Unable to start activity ComponentInfo{my.package.name.classname}: java.lang.RuntimeException: Unable to start activity ComponentInfo{my.package.name.classname}: android.view.InflateException: Binary XML file line #8: Error inflating class fragment
11-20 15:13:39.759: E/AndroidRuntime(2067):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
11-20 15:13:39.759: E/AndroidRuntime(2067):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
11-20 15:13:39.759: E/AndroidRuntime(2067):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-20 15:13:39.759: E/AndroidRuntime(2067):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
11-20 15:13:39.759: E/AndroidRuntime(2067):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 15:13:39.759: E/AndroidRuntime(2067):     at android.os.Looper.loop(Looper.java:130)
11-20 15:13:39.759: E/AndroidRuntime(2067):     at android.app.ActivityThread.main(ActivityThread.java:3687)
11-20 15:13:39.759: E/AndroidRuntime(2067):     at java.lang.reflect.Method.invokeNative(Native Method)
11-20 15:13:39.759: E/AndroidRuntime(2067):     at java.lang.reflect.Method.invoke(Method.java:507)
11-20 15:13:39.759: E/AndroidRuntime(2067):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
11-20 15:13:39.759: E/AndroidRuntime(2067):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
11-20 15:13:39.759: E/AndroidRuntime(2067):     at dalvik.system.NativeStart.main(Native Method)

我不知道为什么和出了什么问题。它不适用于较低版本的Android吗?

先谢谢。

2 个答案:

答案 0 :(得分:1)

尝试使用SupportMapFragment代替MapFragment

答案 1 :(得分:0)

试试兄弟: 在xml中

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