Android-BinaryXMLfileline#8:Errorinflatingclassfragment
Error:
汇川网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站等网站项目制作,到程序开发,运营维护。创新互联从2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。
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:
出错: com.example.news.ArticleReaderFragment
正确的fragment处理类和路径为:
根据网络上一些解决方案,无需将 android.app.Fragment 替换为 android.support.v4.app.Fragment
参考链接:android.support.v4.app.Fragment和android.app.Fragment区别
网页题目:Android-BinaryXMLfileline#8:Errorinflatingclassfragment
URL标题:http://azwzsj.com/article/jsejhh.html