我試圖在片段XML文件中使用coordinatorlayout,但我收到此錯誤。我已經打了一段時間了,現在開始讓我發瘋。Java.Lang.ClassNotFoundException:沒有找到類「android.view.CoordinatorLayout」
我已經嘗試了許多不同的事情,但沒有任何工作。有沒有人有任何想法?
Android.Views.InflateException: Binary XML file line #1: Error inflating class CoordinatorLayout ---> Java.Lang.ClassNotFoundException: Didn't find class "android.view.CoordinatorLayout" on path: DexPathList[[zip file "/data/app/TnpApp.TnpApp-1/base.apk"],nativeLibraryDirectories=[/data/app/TnpApp.TnpApp-1/lib/arm, /vendor/lib, /system/lib]]
at java.lang.ClassNotFoundException: Didn't find class "android.view.CoordinatorLayout" on path: DexPathList[[zip file "/data/app/TnpApp.TnpApp-1/base.apk"],nativeLibraryDirectories=[/data/app/TnpApp.TnpApp-1/lib/arm, /vendor/lib, /system/lib]]
at at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at at android.view.LayoutInflater.createView(LayoutInflater.java:571)
at at android.view.LayoutInflater.onCreateView(LayoutInflater.java:665)
at at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:65)
at at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at at md5be8727c6e6990bc4e9301ed0ea72b54c.TopicalFragment.n_onCreateView(Native Method)
at at md5be8727c6e6990bc4e9301ed0ea72b54c.TopicalFragment.onCreateView(TopicalFragment.java:29)
at at android.app.Fragment.performCreateView(Fragment.java:2069)
at at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:899)
at at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1072)
at at android.app.BackStackRecord.run(BackStackRecord.java:852)
at at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
at at android.app.FragmentManagerImpl$1.run(FragmentManager.java:452)
at at android.os.Handler.handleCallback(Handler.java:815)
at at android.os.Handler.dispatchMessage(Handler.java:104)
at at android.os.Looper.loop(Looper.java:194)
at at android.app.ActivityThread.main(ActivityThread.java:5631)
at at java.lang.reflect.Method.invoke(Native Method)
at at java.lang.reflect.Method.invoke(Method.java:372)
at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
at Suppressed: java.lang.ClassNotFoundException: android.view.CoordinatorLayout
at at java.lang.Class.classForName(Native Method)
at at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
at ... 24 more
at Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
--- End of inner exception stack trace ---
這裏是我的片段XML:
<?xml version="1.0" encoding="utf-8"?>
<CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:adjustViewBounds="true"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#aa000000"
android:fitsSystemWindows="true">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:fitsSystemWindows="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:src="@drawable/commentaryimage"
android:fitsSystemWindows="true" />
<View
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#703c6a87" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
android:src="@drawable/chevron_left"
android:layout_alignParentLeft="true"
android:id="@+id/up_button" />
<TextView
android:text="Topical"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="@android:color/white" />
</RelativeLayout>
</FrameLayout>
<RelativeLayout
android:id="@+id/today"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/topicalList"
android:divider="#309A9A9A"
android:dividerHeight="1px" />
</RelativeLayout>
</LinearLayout>
</CoordinatorLayout>
請參見本教程http://saulmm.github.io/mastering-coordinator,'fill_parent'現已棄用 – DarckBlezzer
@刪除了DarckBlezzer'fill_parent',但這不會影響錯誤。 – Jonathan