在模块 jetified-firebase-jobdispatcher-0.6.0-runtime.jar 中找到 React Native Android Duplicate class com.g

Posted

技术标签:

【中文标题】在模块 jetified-firebase-jobdispatcher-0.6.0-runtime.jar 中找到 React Native Android Duplicate class com.google.android.gms.gcm.PendingCallback【英文标题】:React Native Android Duplicate class com.google.android.gms.gcm.PendingCallback found in modules jetified-firebase-jobdispatcher-0.6.0-runtime.jar 【发布时间】:2021-08-19 07:05:24 【问题描述】:

我的 React Native android 项目遇到问题。我目前正在集成 AWS Amplify Push Notifications。我收到以下“重复类”依赖错误,我不知道它可能来自哪里。你有解决这个问题的办法吗?

我已经做了什么:

我在这里找到了这张票 https://github.com/facebook/react-native/issues/27493 这似乎表明使用 react-native-device-info 可能存在问题,这对我来说就是这种情况。所以我删除了这个库并用 react-native-version-info 替换它。但问题依然存在。 我检查了这张票 https://github.com/dantasfiles/AmplifyAndroidPush/issues/1 - 在运行 ./gradlew :app:dependencies > ../dependencies.txt 时,我得到了依赖关系树,可以看到 com.firebase:firebase-jobdispatcher:0.6.0 似乎仅由 aws amplify 推送通知使用。但是我现在仍然不知道该怎么办:
+--- 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 上还有一个关于此问题的错误,但该错误已被关闭,但没有实际解决方案:( https://github.com/aws-amplify/amplify-js/issues/4593

【问题讨论】:

【参考方案1】:

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

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'

【讨论】:

【参考方案2】:

你好 *** 社区,

经过大约一周的调查并在 aws-amplify-js github 项目中开票后,我现在能够解决问题。在下文中,我想描述一下解决方案,如果你们中的任何人将来可能会遇到同样的问题。

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

在我的 app/build.gradle 中,我有以下与 firebase 和 play-services 相关的定义:

// 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 amplify 推送通知和分析。

只用以下两行替换所有这些定义就可以了,让我可以再次构建我的 Android 应用程序而不会出现重复类错误:

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

最好的 智能家居制造商

【讨论】:

以上是关于在模块 jetified-firebase-jobdispatcher-0.6.0-runtime.jar 中找到 React Native Android Duplicate class com.g的主要内容,如果未能解决你的问题,请参考以下文章

Nde模块篇

FPGA测试的时候需要编写测试模块,即激励模块,在编写测试模块时啥时候需要产生输入激励信号?

如何在 Jahia 7 的其他模块中使用模块的属性?

phpcms如何在首页上添加视频模块

无线WIFI模块主要使用在啥上面?

Python-模块