您好,登錄后才能下訂單哦!
Error:
threadid=1: thread exiting with uncaught exception (group=0x415c5940) FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.wifidirectdemo/com.example.wifidirectdemo.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2227) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2282) at android.app.ActivityThread.access$600(ActivityThread.java:147) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5265) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:760) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267) at android.app.Activity.setContentView(Activity.java:1901) at com.example.wifidirectdemo.MainActivity.onCreate(MainActivity.java:39) at android.app.Activity.performCreate(Activity.java:5146) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2191) ... 11 more Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.news.ArticleListFragment: make sure class name exists, is public, and has an empty constructor that is public at android.app.Fragment.instantiate(Fragment.java:602) at android.app.Fragment.instantiate(Fragment.java:566) at android.app.Activity.onCreateView(Activity.java:4751) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689) ... 21 more Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.news.ArticleListFragment" on path: DexPathList[[zip file "/data/app/com.example.wifidirectdemo-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.wifidirectdemo-1, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) at android.app.Fragment.instantiate(Fragment.java:588) ... 24 more
FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.wifidirectdemo/com.example.wifidirectdemo.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.news.ArticleListFragment: make sure class name exists, is public, and has an empty constructor that is public
istFragment" on path: DexPathList[[zip file "/data/app/com.example.wifidirectdemo-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.wifidirectdemo-1, /vendor/lib, /system/lib]]
XML:
<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="com.example.wifidirectdemo.MainActivity" > <fragment android:name="com.example.news.ArticleListFragment" android:id="@+id/frag_list" android:layout_width="0dp" android:layout_height="match_parent" /> <fragment android:name="com.example.news.ArticleReaderFragment" android:id="@+id/frag_detail" android:layout_width="0dp" android:layout_height="match_parent" /> </RelativeLayout>
出錯: com.example.news.ArticleReaderFragment
正確的fragment處理類和路徑為:
根據(jù)網(wǎng)絡(luò)上一些解決方案,無需將 android.app.Fragment 替換為 android.support.v4.app.Fragment
參考鏈接:android.support.v4.app.Fragment和android.app.Fragment區(qū)別
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。