React Native Android Duplicate类com.google.Android.gms.gcm.Pe



我的React Native Android项目遇到了问题。我目前正在集成AWS Amplify推送通知。我收到以下";重复类"依赖性错误,我不知道它可能来自哪里。你有解决这个问题的办法吗?

我已经做了什么:

  • 我在这里找到了这张票https://github.com/facebook/react-native/issues/27493这似乎表明使用react原生设备信息可能存在问题,我就是这样。所以我删除了这个库,用react原生版本信息替换它。但问题依然存在
  • 我查过这张票https://github.com/dantasfiles/AmplifyAndroidPush/issues/1-当运行./gradlew :app:dependencies > ../dependencies.txt时,我得到了依赖树,可以看到com.firebase:firebase-jobdispatcher:0.6.0似乎只被aws放大推送通知使用。但我现在仍然不知道该怎么办:
+--- project :aws-amplify_pushnotification
...
|    --- com.firebase:firebase-jobdispatcher:0.6.0

有人已经面对这个问题并知道解决方案吗?

提前感谢!

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class com.google.android.gms.gcm.PendingCallback found in modules jetified-firebase-jobdispatcher-0.6.0-runtime.jar (com.firebase:firebase-jobdispatcher:0.6.0) and jetified-play-services-gcm-16.1.0-runtime.jar (com.google.android.gms:play-services-gcm:16.1.0)
Duplicate class com.google.android.gms.internal.measurement.zzu found in modules jetified-firebase-analytics-impl-16.2.4-runtime.jar (com.google.firebase:firebase-analytics-impl:16.2.4) and jetified-play-services-measurement-19.0.0-runtime.jar (com.google.android.gms:play-services-measurement:19.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzv found in modules jetified-firebase-analytics-impl-16.2.4-runtime.jar (com.google.firebase:firebase-analytics-impl:16.2.4) and jetified-play-services-measurement-19.0.0-runtime.jar (com.google.android.gms:play-services-measurement:19.0.0)
Duplicate class com.google.android.gms.internal.measurement.zzw found in modules jetified-firebase-analytics-impl-16.2.4-runtime.jar (com.google.firebase:firebase-analytics-impl:16.2.4) and jetified-play-services-measurement-19.0.0-runtime.jar (com.google.android.gms:play-services-measurement:19.0.0)
Duplicate class com.google.android.gms.measurement.AppMeasurement found in modules jetified-firebase-analytics-impl-16.2.4-runtime.jar (com.google.firebase:firebase-analytics-impl:16.2.4) and jetified-play-services-measurement-impl-19.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:19.0.0)
Duplicate class com.google.android.gms.measurement.AppMeasurement$ConditionalUserProperty found in modules jetified-firebase-analytics-impl-16.2.4-runtime.jar (com.google.firebase:firebase-analytics-impl:16.2.4) and jetified-play-services-measurement-impl-19.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:19.0.0)
Duplicate class com.google.android.gms.measurement.AppMeasurement$EventInterceptor found in modules jetified-firebase-analytics-impl-16.2.4-runtime.jar (com.google.firebase:firebase-analytics-impl:16.2.4) and jetified-play-services-measurement-impl-19.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:19.0.0)
Duplicate class com.google.android.gms.measurement.AppMeasurement$OnEventListener found in modules jetified-firebase-analytics-impl-16.2.4-runtime.jar (com.google.firebase:firebase-analytics-impl:16.2.4) and jetified-play-services-measurement-impl-19.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:19.0.0)
Duplicate class com.google.android.gms.measurement.AppMeasurementContentProvider found in modules jetified-firebase-analytics-impl-16.2.4-runtime.jar (com.google.firebase:firebase-analytics-impl:16.2.4) and jetified-play-services-measurement-impl-19.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:19.0.0)
Duplicate class com.google.android.gms.measurement.internal.zza found in modules jetified-firebase-analytics-impl-16.2.4-runtime.jar (com.google.firebase:firebase-analytics-impl:16.2.4) and jetified-play-services-measurement-impl-19.0.0-runtime.jar (com.google.android.gms:play-services-measurement-impl:19.0.0)
...

GitHub上也有一个关于这个问题的bug,但这个bug已经关闭,没有实际的解决方案:(https://github.com/aws-amplify/amplify-js/issues/4593

如果同一个包中有两个不同的版本,可能会发生这种情况,例如,这将导致错误:

implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation 'com.google.android.gms:play-services-tagmanager:17.0.1'

要解决这个问题,只需使两者的版本相同即可:

implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation 'com.google.android.gms:play-services-tagmanager:17.0.0'

Hi-stackoverflow社区,

经过大约一周的调查,并在aws-amplified-js-github项目中打开了一张罚单,我现在能够解决这个问题了。在下文中,如果你们中的任何人将来可能面临同样的问题,我想描述解决方案。

这是我在aws-amplifier js上创建的github票证:https://github.com/aws-amplify/amplify-js/issues/8389

在我的应用程序/build.gradle中,我有以下与firebase和播放服务相关的定义:

// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:28.0.1')
// Declare the dependencies for the Firebase Cloud Messaging and Analytics libraries
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-analytics'
implementation "com.google.android.gms:play-services-gcm:17.0.0"
...
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-gcm:16.1.0'
force 'com.google.android.gms:play-services-base:16.1.0'
force 'com.google.firebase:firebase-core:16.0.6'
force 'com.google.firebase:firebase-messaging:17.6.0'
}
}

我从不同的资源中获得了这些定义,解释了如何集成aws放大推送通知和分析。

仅用以下两行代码替换所有这些定义就成功了,并允许我再次构建我的Android应用程序,而不会出现重复的类错误:

implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-messaging:15.0.2"

最佳智能家居制造商

相关内容

最新更新