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

前端 未结 4 861
我寻月下人不归
我寻月下人不归 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:04

    I am also new to Android and encountered the same error today. I could not find a solution that worked for me but one thing was clear to me that this issue occurs when android is not able to resolve a mandatory attribute of one of the elements in layout xml.

    So I checked my layout thoroughly and found that by mistake I created an ID

    <item type="id" name="login"/>

    in ids.xml. This Id was conflicting with attribute

    android:imeActionId="@+id/login"

    of EditText element.

    Hope this helps someone.

    0 讨论(0)
  • 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"
    
    0 讨论(0)
  • 2021-01-06 03:22

    In my case Google Maps were not correctly initialized. A message in log console printed about it. I had to add

    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />
    

    to <application> inside AndroidManifest.

    0 讨论(0)
  • 2021-01-06 03:26

    Try adding correct layouts at correct place like ex. in my case I was putting colors.xml in values-w820p then it was giving runtime exception of classtype. I changed the folder from this to simple value and... taffffda!! it worked! :)

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