Android-binary XML file line #8: Error inflating class fragment

Source: Internet
Author: User

Error:

threadid=1: thread exiting with uncaught exception  (group=0x415c5940) FATAL  exception: mainjava.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 fragmentat 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 fragmentat  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 morecaused 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 publicat 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  Morecaused 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:mainjava.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, was public, and have an empty constructor
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>
Error: Com.example.news.ArticleReaderFragment

The correct fragment processing classes and paths are:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/49/E3/wKiom1QeNHbwewX7AAHyknT-2KI396.jpg "title=" Android-xml.png "alt=" Wkiom1qenhbwewx7aahyknt-2ki396.jpg "/>

Based on some solutions on the network, you do not need to replace android.app.Fragment with Android.support.v4.app.Fragment


Reference Links: android.support.v4.app.Fragment and Android.app.Fragment differences

This article is from "Whispering Autumn Wind" blog, please be sure to keep this source http://xjhznick.blog.51cto.com/3608584/1556638

Android-binary XML file line #8: Error inflating class fragment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.