Android Studio Android工作室:膨胀类android.support.design.widget.FloatingActionButton时出错

r7xajy2e  于 2022-11-16  发布在  Android
关注(0)|答案(4)|浏览(294)

今天我试着初始化“ChatSDK”,遇到了一些问题。现在,如果我想启动我的应用程序,它总是崩溃。我发现了这个问题:

E/androidRuntime: FATAL EXEPTION: main   Process: com.inspredunity.gm.germanminelife, PID: 2605
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.inspredunity.gm.germanminelife/com.inspredunity.gm.germanminelife.MainActivity}: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class android.support.design.widget.FloatingActionButton
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 Caused by: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class android.support.design.widget.FloatingActionButton
 Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class android.support.design.widget.FloatingActionButton

E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.FloatingActionButton" on path: DexPathList[[zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/base.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_dependencies_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_resources_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/base.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_dependencies_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_resources_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_0_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_1_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_2_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_3_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_4_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_5_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_6_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_7_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_8_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_9_apk.apk!/lib/x86, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.view.LayoutInflater.createView(LayoutInflater.java:606)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
E/AndroidRuntime:     at com.inspredunity.gm.germanminelife.MainActivity.onCreate(MainActivity.java:37)
    at android.app.Activity.performCreate(Activity.java:7136)
    at android.app.Activity.performCreate(Activity.java:7127)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_resources_apk.apk
    at dalvik.system.DexFile.openDexFileNative(Native Method)
    at dalvik.system.DexFile.openDexFile(DexFile.java:354)
    at dalvik.system.DexFile.<init>(DexFile.java:101)
    at dalvik.system.DexFile.<init>(DexFile.java:75)
    at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
    at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
    at dalvik.system.DexPathList.<init>(DexPathList.java:164)
    at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
    at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
    at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
 at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
    at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
    at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
    at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
    at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
    at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
    at android.app.LoadedApk.getResources(LoadedApk.java:1032)
    at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5749)
    at android.app.ActivityThread.access$1100(ActivityThread.java:199)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)

以下是我的Gradle依赖项:

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplemenstation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.4'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.android.support:design:28.0.0'
implementation 'co.chatsdk.chatsdk:chat-sdk-core:4.4.8'
implementation 'co.chatsdk.chatsdk:chat-sdk-ui:4.4.8'
implementation 'co.chatsdk.chatsdk:chat-sdk-firebase-adapter:4.4.8'
implementation 'co.chatsdk.chatsdk:chat-sdk-firebase-file-storage:4.4.8'
implementation 'com.android.support:recyclerview-v7:28.0.0'

我厌倦了每一个修复建议,我发现在互联网上,但没有工作。我希望你们能帮助我。如果你需要我的主活动或我的gradle文件(s)请说出来!谢谢你提前!

已修复

wydwbb8l

wydwbb8l1#

对于任何人仍然有这个问题后febuary 2019,如果你正在使用androidx或新的材料库,这个问题发生是因为谷歌改变了使用androidx的库的命名格式。.你可以检查这个官方Maphttps://developer.android.com/jetpack/androidx/migrate/artifact-mappings和搜索你的库,看看新的名称是什么,现在谷歌是在androidx
在您的示例中,您的xml文件中的库“android.support.design.widget.FloatingActionButton”现在使用com.google.android.material.floatingActionButton.FloatingActionButton进行调用

oxalkeyp

oxalkeyp2#

**Android支持库不再维护。**因此建议使用AndroidX Library

使用AndroidX的浮动动作按钮:

1.添加到分级中:

implementation 'com.google.android.material:material:1.1.0'

2.在布局中添加:

<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/share_button"
    android:layout_margin="16dp" />
db2dz4w8

db2dz4w83#

您是否将Android支持库添加到您的项目中?如果没有,请尝试以下操作:

implementation "com.android.support:design:28.0.0"

有关如何设置支持库的更多详细信息,您可以查看此https://developer.android.com/topic/libraries/support-library/setup

smdncfj3

smdncfj34#

将此添加到您的Gradle中:

implementation com.android.support:design:28.0.0

相关问题