android.view.InflateException: Binary XML file line #10: Error inflating class fragment

前端 未结 4 868
我寻月下人不归
我寻月下人不归 2021-01-06 02:30

I created an app by following the tutorial at http://www.techotopia.com/index.php/Using_Fragments_in_Android_-_A_Worked_Example, but I have a error.

LogCat:<

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-06 03:14

    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.fragmentexample.ToolbarFragment" on path: DexPathList[[zip file "/data/app/com.example.myfragmentexample-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.myfragmentexample-1, /system/lib]]

    This

    android:name="com.example.fragmentexample.ToolbarFragment"
    

    Must be

    android:name="com.example.myfragmentexample.ToolbarFragment"
    

    cause package name for ToolbarFragment.java is

    package com.example.myfragmentexample;
    

    Similarly for TextFragment

    android:name="com.example.myfragmentexample.TextFragment"
    

提交回复
热议问题