Error inflating class fragment

后端 未结 30 2189
长发绾君心
长发绾君心 2020-11-22 14:38

I get the Error

Unable to start activity ComponentInfo{de.androidbuch.activiti/de.androidbuch.activiti.task.Activity}: android.view.InflateException: Binar         


        
相关标签:
30条回答
  • 2020-11-22 15:04

    Had the same error type, where exactly the same error message in logcat was displayed. I needed to make changes in the Java Build Path located under Project->Properties. I had included Google Maps related libraries like android-support-v4.jar and google-play-services.jar; however I was missing including these on the 'Build class path' in the 'Order and Export' option menu. Maybe the error lies here.

    Try including libraries to the build class path.

    The order of which the classes are built might also trigger the error, so my advice is also to try to rearrange the order of the building path. The error disappeared when I used the following order: 'my_project_name/src'->'my_project_name/gen'->'Android Private Libraries'. The last unit contains the jar files mentioned earlier.

    0 讨论(0)
  • 2020-11-22 15:05

    In your xml file just use a instead of the tag. The inflater tries to create an android.app.Fragment from which will fail on API < 10. So you need to create a view group of a different type.

    0 讨论(0)
  • 2020-11-22 15:06

    Make sure there is no exception raised in the onCreateView method of the fragment. If any exception is raised in this method, logcat won't show exact details of the exception, instead it always shows the message:

    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.fragment" 
    on path: DexPathList[[zip file "/data/app/com.package/base.apk"],
    nativeLibraryDirectories=[/data/app/com.package/lib/arm64, /vendor/lib64, /system/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    
    0 讨论(0)
  • 2020-11-22 15:07

    Make sure your Activity extends FragmentActivity.

    0 讨论(0)
  • 2020-11-22 15:07

    If you want to inherit the AppCompatActivity, then you can do something like this- In the activity xml, use a FrameLayout like this-

    <FrameLayout
        android:id="@+id/result_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/progress_frame"/>
    

    and in the activity onCreate-

    final FragmentManager supportFragmentManager = getSupportFragmentManager();
        FragmentTransaction ft = supportFragmentManager.beginTransaction();
        ft.replace(R.id.result_fragment, fphResultActivityFragment, "result fragment");
        ft.commitAllowingStateLoss();
    
    0 讨论(0)
  • 2020-11-22 15:08

    Just had this same error. The reason for mine was the visibility of my fragment class. It was set to default, should be public.

    0 讨论(0)
提交回复
热议问题