在谷歌地图API中错误膨胀类片段错误

时间:2014-03-24 22:51:57

标签: android xml google-maps

尝试将地图片段插入项目时出现以下错误。我不能为我的生活想象我们正在发生的事情......我已经绞尽脑汁想要按照基本教程中的说明逐字逐句地完成这项工作,我仍然陷入困境。

03-24 15:28:38.740: E/AndroidRuntime(3683): FATAL EXCEPTION: main
03-24 15:28:38.740: E/AndroidRuntime(3683): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.main.pkg/com.main.pkg.NewHomepage}: android.view.InflateException: Binary XML file line #41: Error inflating class fragment
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.os.Looper.loop(Looper.java:137)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.ActivityThread.main(ActivityThread.java:5103)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at java.lang.reflect.Method.invokeNative(Native Method)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at java.lang.reflect.Method.invoke(Method.java:525)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at dalvik.system.NativeStart.main(Native Method)
03-24 15:28:38.740: E/AndroidRuntime(3683): Caused by: android.view.InflateException: Binary XML file line #41: Error inflating class fragment
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.Activity.setContentView(Activity.java:1895)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at com.main.pkg.NewHomepage.onCreate(NewHomepage.java:34)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.Activity.performCreate(Activity.java:5133)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
03-24 15:28:38.740: E/AndroidRuntime(3683):     ... 11 more
03-24 15:28:38.740: E/AndroidRuntime(3683): Caused by: android.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
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.Fragment.instantiate(Fragment.java:592)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.Fragment.instantiate(Fragment.java:560)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.Activity.onCreateView(Activity.java:4738)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
03-24 15:28:38.740: E/AndroidRuntime(3683):     ... 22 more
03-24 15:28:38.740: E/AndroidRuntime(3683): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapFragment" on path: DexPathList[[zip file "/data/app/com.main.pkg-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.main.pkg-1, /system/lib]]
03-24 15:28:38.740: E/AndroidRuntime(3683):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-24 15:28:38.740: E/AndroidRuntime(3683):     at android.app.Fragment.instantiate(Fragment.java:582)
03-24 15:28:38.740: E/AndroidRuntime(3683):     ... 25 more'

这是我的XML:

<RelativeLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    >

    <TextView
    android:id="@+id/number_mail"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toLeftOf="@+id/mail_button"
    android:layout_marginRight="7dp"
    android:layout_marginTop="9dp"
    android:textColor="#f900"
    />

    <Button
    android:background="@drawable/button_image"
    android:layout_width="26dp"
    android:layout_height="19dp"
    android:layout_alignParentRight="true"
    android:layout_marginRight="5dp"
    android:layout_marginTop="5dp"
    android:id="@+id/mail_button"
    />
            <LinearLayout 

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginTop="50dp"
            >
            <TextView
            android:id="@+id/firstname"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />

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




            </LinearLayout>

</RelativeLayout>

我尝试过使用过com.google.android.gms.maps.SupportMapFragment&#39;相反,但我得到了同样的错误。

我可能会在这里失踪什么?我的清单似乎有正确的信息。

0 个答案:

没有答案