自从我向我的 Flutter 应用程序添加云消息传递以来,该应用程序在加载时崩溃。
它在iOS上运行良好。
据我所知,它的所有设置都正确,而且它在iOS上运行的事实我很茫然。
这是日志猫文件
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/internal/InternalTokenProvider;
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at com.google.firebase.components.ComponentDiscovery.instantiate(com.google.firebase:firebase-common@@17.0.0:78)
at com.google.firebase.components.ComponentDiscovery.discover(com.google.firebase:firebase-common@@17.0.0:71)
at com.google.firebase.FirebaseApp.<init>(com.google.firebase:firebase-common@@17.0.0:468)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@17.0.0:354)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@17.0.0:321)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@17.0.0:305)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@17.0.0:53)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1917)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1892)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@17.0.0:47)
at android.app.ActivityThread.installProvider(ActivityThread.java:6391)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5938)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5853)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
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)
2019-06-05 13:02:06.390 7346-7346/? E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.internal.InternalTokenProvider" on path: DexPathList[[zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/base.apk", zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_dependencies_apk.apk", zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_resources_apk.apk", zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_0_apk.apk", zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_1_apk.apk", zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_2_apk.apk", zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_3_apk.apk", zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_4_apk.apk", zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_5_apk.apk", zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_6_apk.apk", zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_7_apk.apk", zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_8_apk.apk", zip file "/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/base.apk!/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_dependencies_apk.apk!/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_resources_apk.apk!/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_0_apk.apk!/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_1_apk.apk!/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_2_apk.apk!/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_3_apk.apk!/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_4_apk.apk!/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_5_apk.apk!/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_6_apk.apk!/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_7_apk.apk!/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/split_lib_slice_8_apk.apk!/lib/x86, /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/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)
... 24 more
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/org.heartchurch.heartland-M4kZV3m1AevnHc2GxsBI5A==/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)
2019-06-05 13:02:06.391 7346-7346/? E/AndroidRuntime: 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)
... 8 more
我已确保将以下内容添加到我的清单中
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
打开安卓
项目。
去 build.gradle of firebase_messaging
在依赖项中,api 'com.google.firebase:firebase-messaging:18.0.0'
更改为 api 'com.google.firebase:firebase-messaging:17.3.3'
确保您使用的是 pubspec.yaml 中所有云依赖项的最新版本
这个解决方案对我有用