无法在 Android 中使用 Firebase 应用内消息?
Posted
技术标签:
【中文标题】无法在 Android 中使用 Firebase 应用内消息?【英文标题】:Unable to use Firebase in-app messaging in Android? 【发布时间】:2019-01-26 17:57:32 【问题描述】:我正在尝试在我的 android 应用中实现新的 Firebase 应用内消息传递功能。但无论出于何种原因,当我将库添加到我的 gradle 时,该应用就崩溃了。
这是我的毕业典礼:
implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
我在这里给出了 poicasso,因为在崩溃日志中我收到了与 picasso 相关的错误
这是日志文件:
08-19 18:10:08.482 26606-26606/com.kirtu.simpletexts.texts.debug E/CrashlyticsCore: Failed to execute task.
java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:177)
at com.crashlytics.android.core.CrashlyticsBackgroundWorker.submitAndWait(CrashlyticsBackgroundWorker.java:41)
at com.crashlytics.android.core.CrashlyticsController.handleUncaughtException(CrashlyticsController.java:320)
at com.crashlytics.android.core.CrashlyticsController$6.onUncaughtException(CrashlyticsController.java:300)
at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler.uncaughtException(CrashlyticsUncaughtExceptionHandler.java:42)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
08-19 18:10:08.484 26606-26606/com.kirtu.simpletexts.texts.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.kirtu.simpletexts.texts.debug, PID: 26606
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/picasso/OkHttpDownloader;
at com.google.firebase.inappmessaging.display.internal.b.b.zzr.get(com.google.firebase:firebase-inappmessaging-display@@17.0.0:2038)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.google.firebase.inappmessaging.display.internal.zzf.get(com.google.firebase:firebase-inappmessaging-display@@17.0.0:1021)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.google.firebase.inappmessaging.display.zzb.get(com.google.firebase:firebase-inappmessaging-display@@17.0.0:1062)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.google.firebase.inappmessaging.display.internal.b.a.zzb.zza(com.google.firebase:firebase-inappmessaging-display@@17.0.0:104)
at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplayRegistrar.zza(com.google.firebase:firebase-inappmessaging-display@@17.0.0:1058)
at com.google.firebase.inappmessaging.display.zza.create(com.google.firebase:firebase-inappmessaging-display@@17.0.0)
at com.google.firebase.components.zzh.zza(com.google.firebase:firebase-common@@16.0.1:29)
at com.google.firebase.components.zzi.get(com.google.firebase:firebase-common@@16.0.1)
at com.google.firebase.components.zzh.get(com.google.firebase:firebase-common@@16.0.1:40)
at com.google.firebase.components.ComponentContainer$$CC.get(com.google.firebase:firebase-common@@16.0.1:15)
at com.google.firebase.components.zzd.get(com.google.firebase:firebase-common@@16.0.1)
at com.google.firebase.components.zzd.zza(com.google.firebase:firebase-common@@16.0.1:68)
at com.google.firebase.FirebaseApp.zze(com.google.firebase:firebase-common@@16.0.1:716)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@16.0.1:329)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@16.0.1:295)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@16.0.1:282)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@16.0.1:37)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@16.0.1:31)
at android.app.ActivityThread.installProvider(ActivityThread.java:5977)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5547)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5486)
at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:360)
at android.app.ActivityThread.handleBindApplication(<Xposed>)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1575)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6243)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.squareup.picasso.OkHttpDownloader" on path: DexPathList[[zip file "/data/app/com.kirtu.simpletexts.texts.debug-2/base.apk", zip file "/data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.kirtu.simpletexts.texts.debug-2/lib/arm64, /data/app/com.kirtu.simpletexts.texts.debug-2/base.apk!/lib/arm64-v8a, /data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_dependencies_apk.apk!/lib/arm64-v8a, /data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_0_apk.apk!/lib/arm64-v8a, /data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_2_apk.apk!/lib/arm64-v8a, /data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_3_apk.apk!/lib/arm64-v8a, /data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_4_apk.apk!/lib/arm64-v8a, /data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_5_apk.apk!/lib/arm64-v8a, /data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_6_apk.apk!/lib/arm64-v8a, /data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_7_apk.apk!/lib/arm64-v8a, /data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_8_apk.apk!/lib/arm64-v8a, /data/app/com.kirtu.simpletexts.texts.debug-2/split_lib_slice_9_apk.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 38 more
08-19 18:10:08.723 834-12882/? E/linker: readlink("/proc/self/fd/276") failed: Permission denied [fd=276]
检查与毕加索第 12 行有关的内容。
如果我需要提供任何东西,请告诉我。
【问题讨论】:
【参考方案1】:到目前为止,我发现了解决方案,很抱歉这么晚才回答。
In-AppMessaging 是用毕加索 2.5.2 版编程的,所以如果你用最新版本编译它,它会给你一个:
java.lang.NoClassDefFoundError error.
要修复它,您必须降级 Gradle 的 Picasso 版本,或者像我一样将其删除:
//implementation 'com.squareup.picasso:picasso:2.71828'
由于应用内消息库已经集成了 Picasso,因此您无需在应用的 build.gradle 中注册它。
你必须做的另一件事是,因为你有新的集成:
Picasso.get()
您必须更改它以实现 2.5.2 版:
Picasso.with(context)
我希望这可以修复您的错误,就像在我的编译中修复的一样。
编辑:为了补充应用内消息集成主题,这些是库使用的库:
+--- com.google.firebase:firebase-inappmessaging:17.0.0
| | +--- com.google.android.gms:play-services-clearcut:15.0.1 (*)
| | +--- com.google.auto.value:auto-value-annotations:1.6
| | +--- com.google.dagger:dagger:2.13 (*)
| | +--- com.google.firebase:firebase-common:16.0.1 (*)
| | +--- com.google.firebase:firebase-iid:16.0.0 -> 17.0.0 (*)
| | +--- com.google.firebase:firebase-measurement-connector:17.0.0 (*)
| | +--- com.google.firebase:protolite-well-known-types:16.0.0
| | | \--- com.google.protobuf:protobuf-lite:3.0.1
| | +--- io.grpc:grpc-okhttp:1.12.0
| | | +--- io.grpc:grpc-core:[1.12.0] -> 1.12.0
| | | | +--- io.grpc:grpc-context:1.12.0
| | | | +--- com.google.code.gson:gson:2.7
| | | | +--- com.google.guava:guava:20.0
| | | | +--- com.google.errorprone:error_prone_annotations:2.1.2
| | | | +--- com.google.code.findbugs:jsr305:3.0.0 -> 3.0.1
| | | | +--- io.opencensus:opencensus-api:0.11.0
| | | | \--- io.opencensus:opencensus-contrib-grpc-metrics:0.11.0
| | | | \--- io.opencensus:opencensus-api:0.11.0
| | | +--- com.squareup.okhttp:okhttp:2.5.0 -> 2.7.5
| | | | \--- com.squareup.okio:okio:1.6.0 -> 1.14.0
| | | \--- com.squareup.okio:okio:1.13.0 -> 1.14.0
| | +--- io.grpc:grpc-protobuf-lite:1.12.0
| | | +--- io.grpc:grpc-core:1.12.0 (*)
| | | +--- com.google.protobuf:protobuf-lite:3.0.1
| | | \--- com.google.guava:guava:20.0
| | +--- io.grpc:grpc-stub:1.12.0
| | | \--- io.grpc:grpc-core:1.12.0 (*)
| | +--- io.reactivex.rxjava2:rxandroid:2.0.2
| | | \--- io.reactivex.rxjava2:rxjava:2.1.9 -> 2.1.14
| | | \--- org.reactivestreams:reactive-streams:1.0.2
| | \--- io.reactivex.rxjava2:rxjava:2.1.14 (*)
| +--- com.squareup.okhttp:okhttp:2.7.5 (*)
| \--- com.squareup.picasso:picasso:2.5.2 -> 2.71828 (*)
【讨论】:
它成功了,让我知道在此之后是否可以进行任何优化。 此解决方案适用于 pre android P 设备。由于某种原因,在使用 Android P 时根本无法加载图像....我正在考虑切换到 glide 看看是否会更好 我认为这不是一个正确的答案,因为如果毕加索不是我们可以期待的选择,那么降级。 @RuslanBerozov 我与 Firebase 支持人员进行了交谈,即使在用户打开应用程序内消息并关闭应用程序时也存在许多错误,因为毕加索在该版本中处理图像加载.但他们不想解决这个问题。 已经出版本 firebase-inappmessaging-display 18.0.2,它使用了 Picasso 的 2.71828 版本。 firebase.google.com/support/release-notes/…以上是关于无法在 Android 中使用 Firebase 应用内消息?的主要内容,如果未能解决你的问题,请参考以下文章
无法使用cordova在android上获得firebase oauth
图像加载和上传到 Firebase 存储无法在 android 和 firebase 控制台中显示“错误加载预览”
如何使用firebase auth android无法返回android
Firebase 动态链接 - 从 Play 商店安装应用程序后无法在 android 中获取 Url