How to Solve Error inflating class android.support.design.widget.FloatingActionButton

Problem Description

Floating box style is abnormal


 Caused by: android.view.InflateException: Binary XML file line #10 in com.example.administrator.myapplication:layout/activity_event_simple: Binary XML file line #10 in com.example.administrator.myapplication:layout/activity_event_simple: Error inflating class android.support.design.widget.FloatingActionButton
     Caused by: android.view.InflateException: Binary XML file line #10 in com.example.administrator.myapplication:layout/activity_event_simple: Error inflating class android.support.design.widget.FloatingActionButton
     Caused by: java.lang.ClassNotFoundException: android.support.design.widget.FloatingActionButton
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:454)
        at android.view.LayoutInflater.createView(LayoutInflater.java:813)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1004)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1121)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:680)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.administrator.myapplication.event.EventSimpleActivity.onCreate(EventSimpleActivity.java:16)
        at android.app.Activity.performCreate(Activity.java:8000)
        at android.app.Activity.performCreate(Activity.java:7984)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.FloatingActionButton" on path: DexPathList[[zip file "/data/app/~~ifhZZYKrV3-7IC9EpRYwtQ==/com.example.administrator.myapplication-dVeo5FiMTqcAMDRaRAmCew==/base.apk"],nativeLibraryDirectories=[/data/app/~~ifhZZYKrV3-7IC9EpRYwtQ==/com.example.administrator.myapplication-dVeo5FiMTqcAMDRaRAmCew==/lib/x86, /system/lib, /system_ext/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        	... 28 more

Solutions
Check whether to add the corresponding dependency

Specific code
Add
implementation’com.android.support: design:28.0.0 ‘ in build.gradle


dependencies {
    implementation 'com.android.support:design:28.0.0'
}

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *