2021年1月27日星期三

Cordova - Android Error "Duplicate Class"

I'm attempting to add a google analytics plugin to a project via cordova and it's resulting in this duplicate class build error when I compile for android

Duplicate class com.google.android.gms.actions.ReserveIntents found in modules google-play-services.jar (google-play-services.jar) and play-services-basement-16.2.0-runtime.jar (com.google.android.gms:play-services-basement:16.2.0)  Duplicate class com.google.android.gms.ads.identifier.AdvertisingIdClient found in modules google-play-services.jar (google-play-services.jar) and play-services-ads-identifier-16.0.0-runtime.jar (com.google.android.gms:play-services-ads-identifier:16.0.0)  Duplicate class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info found in modules google-play-services.jar (google-play-services.jar) and play-services-ads-identifier-16.0.0-runtime.jar (com.google.android.gms:play-services-ads-identifier:16.0.0)  Duplicate class com.google.android.gms.analytics.CampaignTrackingReceiver found in modules google-play-services.jar (google-play-services.jar) and play-services-analytics-impl-16.0.1-runtime.jar (com.google.android.gms:play-services-analytics-impl:16.0.1)  ...   Duplicate class com.google.android.gms.tagmanager.InstallReferrerReceiver found in modules google-play-services.jar (google-play-services.jar) and play-services-tagmanager-v4-impl-16.0.1-runtime.jar (com.google.android.gms:play-services-tagmanager-v4-impl:16.0.1)  Duplicate class com.google.android.gms.tagmanager.InstallReferrerService found in modules google-play-services.jar (google-play-services.jar) and play-services-tagmanager-v4-impl-16.0.1-runtime.jar (com.google.android.gms:play-services-tagmanager-v4-impl:16.0.1)  Duplicate class com.google.android.gms.tagmanager.PreviewActivity found in modules google-play-services.jar (google-play-services.jar) and play-services-tagmanager-v4-impl-16.0.1-runtime.jar (com.google.android.gms:play-services-tagmanager-v4-impl:16.0.1)  Duplicate class com.google.android.gms.tagmanager.TagManager found in modules google-play-services.jar (google-play-services.jar) and play-services-tagmanager-v4-impl-16.0.1-runtime.jar (com.google.android.gms:play-services-tagmanager-v4-impl:16.0.1)    Go to the documentation to learn how to Fix dependency resolution errors.  

After scouring the web for a bit the most promising solution I could find was adding the following to the build.gradle for android.app

android {      configurations.all {          resolutionStrategy {              force 'com.google.android.gms:play-services-ads-identifier:16.0.0'              force 'com.google.android.gms:play-services-analytics-impl:16.0.1'              force 'com.google.android.gms:play-services-basement:16.2.0'              force 'com.google.android.gms:play-services-measurement-sdk-api:16.5.0'          }      }        ...  }  

This didn't seem to change the build error in the least. What's sure way to get around this issue ?

Extra Info

  • cordova plugin add cordova-plugin-google-analytics
  • <preference name="android-minSdkVersion" value="22" />
https://stackoverflow.com/questions/65930461/cordova-android-error-duplicate-class January 28, 2021 at 11:04AM

没有评论:

发表评论