当我上次进行一些更改时,该应用程序运行良好。但是突然遇到了firebase的问题。
implementation project(':react-native-firebase')
implementation 'com.android.support:support-v4:+'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation project(':react-native-device-info')
implementation project(':react-native-vector-icons')
implementation fileTree(dir: "libs", include: ["*.jar"])
..... other dependencies
implementation 'com.google.firebase:firebase-messaging:16.1.0
出现错误
Duplicate class com.google.android.gms.internal.firebase_messaging.zza found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.android.gms.internal.firebase_messaging.zzb found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.android.gms.internal.firebase_messaging.zzc found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.android.gms.internal.firebase_messaging.zzd found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.android.gms.internal.firebase_messaging.zze found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.android.gms.internal.firebase_messaging.zzf found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.android.gms.internal.firebase_messaging.zzh found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.android.gms.internal.firebase_messaging.zzm found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.android.gms.internal.firebase_messaging.zzn found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.android.gms.internal.firebase_messaging.zzo found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.android.gms.internal.firebase_messaging.zzp found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.android.gms.internal.firebase_messaging.zzq found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.android.gms.internal.firebase_messaging.zzr found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Duplicate class com.google.firebase.iid.FirebaseInstanceIdReceiver found in modules jetified-firebase-iid-17.1.2-runtime.jar (com.google.firebase:firebase-iid:17.1.2) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)
Go to the documentation to learn how to Fix dependency resolution errors.
答案 0 :(得分:8)
我在这里遇到了同样的问题,突然 android 停止工作。我正在使用 react-native 0.61.5。
您可以通过以下三种方法解决此问题:
第一种方法:(解决了我的问题) 在您的 android/build.gradle 上将此行添加到 ext 部分:
firebaseVersion = "21.1.0"
第二种方式:(也解决了我的问题) 如果第一种方法不起作用,也许你应该多做一点。在您的 android/buld.gradle 中:
firebaseMessagingVersion = "21.1.0"
buildToolsVersion = "29.0.2"
firebaseCoreVersion = "17.0.0"
firebaseVersion = "21.1.0"
在您的 android/app/build.gradle 上,添加:
implementation 'com.google.firebase:firebase-messaging:21.1.0'
第三种方式
您需要找到所有影响您的应用程序的 firebase 依赖项,注意使用与 firebase 相关的东西的 node_modules 依赖项。映射所有依赖项后,您需要在 android/build.gradle 和 android/app/build.gradle 上指定版本。
注意事项: 对不起我的英语,我试过了。
答案 1 :(得分:1)
我遇到了这个问题,我发现 firebase-iid 在与 firebase-messaging 相同的版本上工作,但现在消息版本是 22.0.0,而 firebase-iid 的市长版本是 21.1.0,所以你有将依赖项与每个对应的版本分开。