导致类android.support.design.widget.FloatingActionButton膨胀的错误
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了导致类android.support.design.widget.FloatingActionButton膨胀的错误相关的知识,希望对你有一定的参考价值。
日志
2020-05-16 22:37:48.842 6238-6238 / com.example.pets E / androidRuntime:致命异常:main流程:com.example.pets,PID:6238java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.pets / com.example.pets.MainActivity}:android.view.InflateException:二进制XML文件行#15:二进制XML文件行#15:错误膨胀类android.support.design.widget.FloatingActionButton在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)在android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)在android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)在android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1808)在android.os.Handler.dispatchMessage(Handler.java:106)在android.os.Looper.loop(Looper.java:193)在android.app.ActivityThread.main(ActivityThread.java:6669)在java.lang.reflect.Method.invoke(本机方法)在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:493)在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)引起原因:android.view.InflateException:二进制XML文件第15行:二进制XML文件第15行:错误膨胀了类android.support.design.widget.FloatingActionButton原因:android.view.InflateException:二进制XML文件第15行:错误膨胀了类android.support.design.widget.FloatingActionButton原因:java.lang.ClassNotFoundException:在路径:DexPathList [[zip文件“ /data/app/com.example.pets-yDldPR2WAVsZuns7zd4oFA==/base”中找不到类“ android.support.design.widget.FloatingActionButton” .apk“],nativeLibraryDirectories = [/ data / app / com.example.pets-yDldPR2WAVsZuns7zd4oFA == / lib / x86,/ system / lib]]在dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)在java.lang.ClassLoader.loadClass(ClassLoader.java:379)在java.lang.ClassLoader.loadClass(ClassLoader.java:312)在android.view.LayoutInflater.createView(LayoutInflater.java:606)在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)在android.view.LayoutInflater.rInflate(LayoutInflater.java:863)在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)在android.view.LayoutInflater.inflate(LayoutInflater.java:515)在android.view.LayoutInflater.inflate(LayoutInflater.java:423)在android.view.LayoutInflater.inflate(LayoutInflater.java:374)在androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)在androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)在com.example.pets.MainActivity.onCreate(MainActivity.java:18)在android.app.Activity.performCreate(Activity.java:7136)在android.app.Activity.performCreate(Activity.java:7127)在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)在android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)在android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)在android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1808)在android.os.Handler.dispatchMessage(Handler.java:106)在android.os.Looper.loop(Looper.java:193)在android.app.ActivityThread.main(ActivityThread.java:6669)在java.lang.reflect.Method.invoke(本机方法)在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:493)在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)2020-05-16 22:37:48.898 6238-6238 / com.example.pets I / Process:正在发送信号。 PID:6238 SIG:9
依赖项{实现fileTree(dir:'libs',包括:['* .jar'])
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.support:design:29.0.0'
}
我想这会帮到您
并且也不要忘记在gradle文件中添加材料库。
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:src="@drawable/ic_my_icon"
android:contentDescription="@string/submit"
android:layout_margin="16dp" />
添加'com.google.android.material:material:1.0.0'
而不是'com.android.support:design:29.0.0'
首先:com.android.support:design:29.0.0
不存在。我怀疑您提供的Gradle代码实际上是否可以因此而编译,因此您应该首先删除该行。
第二,您正在尝试填充android.support.design.widget.FloatingActionButton
,这是已弃用的旧支持库类。您应该使用的(从已经添加的Material依赖项中选择)为com.google.android.material.floatingactionbutton.FloatingActionButton
。您需要用com.google.android.material.floatingactionbutton.FloatingActionButton
等效项替换XML中android.support.design
小部件的所有实例。
以上是关于导致类android.support.design.widget.FloatingActionButton膨胀的错误的主要内容,如果未能解决你的问题,请参考以下文章
无法访问类“android.support.design.widget.Snackbar”
如何修复“错误膨胀类 android.support.design.widget.NavigationView”
InflateException 膨胀类 android.support.design.widget.CoordinatorLayout 时出错
在 Xamarin 中膨胀类 android.support.design.widget.Coordinator 时出错
在android中夸大类android.support.design.widget.CollapsingToolbarLayout的错误