Android Fragments Google Maps API V2片段无法膨胀

8ftvxx2r  于 12个月前  发布在  Android
关注(0)|答案(1)|浏览(146)

这是我第一次开发Android应用程序,我的第一个目标是使一个简单的Map控件出现在屏幕上。代码和一切看起来都很好,除了在我的2.3.7手机上运行时应用程序崩溃的事实!我使用的是从谷歌API v2页面的例子,它仍然不工作。
我的Android手机运行的是2.3.7 Android版本。
代码:

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MapActivity" >

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

字符串
这是怎么回事?

08-15 00:06:46.230: E/ActivityThread(11383): Failed to inflate
08-15 00:06:46.230: E/ActivityThread(11383): android.view.InflateException: Binary XML file line #11: Error inflating class fragment
08-15 00:06:46.230: E/ActivityThread(11383):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-15 00:06:46.230: E/ActivityThread(11383):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:213)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.app.Activity.setContentView(Activity.java:1657)
08-15 00:06:46.230: E/ActivityThread(11383):    at com.cefetmgrdctcc.sgtp.MapActivity.onCreate(MapActivity.java:13)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.app.ActivityThread.access$1500(ActivityThread.java:123)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.os.Looper.loop(Looper.java:130)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.app.ActivityThread.main(ActivityThread.java:3835)
08-15 00:06:46.230: E/ActivityThread(11383):    at java.lang.reflect.Method.invokeNative(Native Method)
08-15 00:06:46.230: E/ActivityThread(11383):    at java.lang.reflect.Method.invoke(Method.java:507)
08-15 00:06:46.230: E/ActivityThread(11383):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
08-15 00:06:46.230: E/ActivityThread(11383):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
08-15 00:06:46.230: E/ActivityThread(11383):    at dalvik.system.NativeStart.main(Native Method)
08-15 00:06:46.230: E/ActivityThread(11383): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.cefetmgrdctcc.sgtp-2.apk]
08-15 00:06:46.230: E/ActivityThread(11383):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
08-15 00:06:46.230: E/ActivityThread(11383):    at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
08-15 00:06:46.230: E/ActivityThread(11383):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.view.LayoutInflater.createView(LayoutInflater.java:471)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
08-15 00:06:46.230: E/ActivityThread(11383):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
08-15 00:06:46.230: E/ActivityThread(11383):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
08-15 00:06:46.230: E/ActivityThread(11383):    ... 20 more
08-15 00:06:46.238: D/AndroidRuntime(11383): Shutting down VM
08-15 00:06:46.238: W/dalvikvm(11383): threadid=1: thread exiting with uncaught exception (group=0x40018560)
08-15 00:06:46.246: E/AndroidRuntime(11383): FATAL EXCEPTION: main
08-15 00:06:46.246: E/AndroidRuntime(11383): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cefetmgrdctcc.sgtp/com.cefetmgrdctcc.sgtp.MapActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.app.ActivityThread.access$1500(ActivityThread.java:123)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.os.Looper.loop(Looper.java:130)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.app.ActivityThread.main(ActivityThread.java:3835)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at java.lang.reflect.Method.invokeNative(Native Method)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at java.lang.reflect.Method.invoke(Method.java:507)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at dalvik.system.NativeStart.main(Native Method)
08-15 00:06:46.246: E/AndroidRuntime(11383): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:213)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.app.Activity.setContentView(Activity.java:1657)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at com.cefetmgrdctcc.sgtp.MapActivity.onCreate(MapActivity.java:13)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
08-15 00:06:46.246: E/AndroidRuntime(11383):    ... 11 more
08-15 00:06:46.246: E/AndroidRuntime(11383): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.cefetmgrdctcc.sgtp-2.apk]
08-15 00:06:46.246: E/AndroidRuntime(11383):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.view.LayoutInflater.createView(LayoutInflater.java:471)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
08-15 00:06:46.246: E/AndroidRuntime(11383):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
08-15 00:06:46.246: E/AndroidRuntime(11383):    ... 20 more

xdnvmnnf

xdnvmnnf1#

你应该使用com.google.android.gms.maps.SupportMapFragment

相关问题