今天,我尝试初始化“ 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'
androidTestImplementation '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'
我厌倦了在互联网上找到的所有修复建议,但没有任何效果:(。我希望你们能帮助我。 如果您需要我的MainActivity或我的grandle文件,请说出来! 先感谢您!
已修复
答案 0 :(得分:9)
不再支持Android支持库。因此,建议改用AndroidX Library。
使用AndroidX的FloatingActionButton:
1。添加gradle:
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" />
答案 1 :(得分:3)
对于在2019年2月之后仍然存在此问题的任何人,如果您使用的是androidx或新的材料库,则会发生此问题,因为Google使用androidx更改了库的命名格式。您可以检查此正式映射{{ 3}} 并搜索您的库以查看新名称,因为Google位于androidx
在您的情况下,xml文件中的库“ android.support.design.widget.FloatingActionButton ”现在称为使用 com.google.android.material.floatingactionbutton。 FloatingActionButton
答案 2 :(得分:0)
您是否向项目添加了android支持库?如果没有尝试过这个:
implementation "com.android.support:design:28.0.0"
有关如何设置支持库的更多详细信息,您可以检查一下 https://developer.android.com/topic/libraries/support-library/setup
答案 3 :(得分:0)
将此添加到您的gradle中:
implementation com.android.support:design:28.0.0