Android Duplicate class error on while using nav sdk and map sdk

307 views Asked by At

I want to use Google map and Navigation SDK Both but getting Duplicate class error. If excludes 'com.google.android.gms' SupportMapFragment and other map classes are not found.

Following implementations are used

implementation "com.google.android.gms:play-services-maps:17.0.0"
implementation "com.google.android.gms:play-services-location:17.0.0"
implementation 'com.google.android.maps:navsdk:3.2.0' 
implementation 'com.google.android.libraries.mapsplatform.transportation:transportation-driver:4.0.0'

Following dependencies are added

Duplicate class com.google.android.gms.maps.CameraUpdate found in modules jetified-navsdk-4.3.2-runtime (com.google.android.maps:navsdk:4.3.2) and jetified-play-services-maps-17.0.0-runtime (com.google.android.gms:play-services-maps:17.0.0) Duplicate class com.google.android.gms.maps.CameraUpdateFactory found in modules jetified-navsdk-4.3.2-runtime (com.google.android.maps:navsdk:4.3.2) and jetified-play-services-maps-17.0.0-runtime (com.google.android.gms:play-services-maps:17.0.0) Duplicate class com.google.android.gms.maps.GoogleMap found in modules jetified-navsdk-4.3.2-runtime (com.google.android.maps:navsdk:4.3.2) and jetified-play-services-maps-17.0.0-runtime (com.google.android.gms:play-services-maps:17.0.0) Duplicate class com.google.android.gms.maps.GoogleMap$CancelableCallback found in modules jetified-navsdk-4.3.2-runtime (com.google.android.maps:navsdk:4.3.2) and jetified-play-services-maps-17.0.0-runtime (com.google.android.gms:play-services-maps:17.0.0) Duplicate class com.google.android.gms.maps.GoogleMap$InfoWindowAdapter found in modules jetified-navsdk-4.3.2-runtime (com.google.android.maps:navsdk:4.3.2) and jetified-play-services-maps-17.0.0-runtime (com.google.android.gms:play-services-maps:17.0.0) Duplicate class com.google.android.gms.maps.GoogleMap$OnCameraChangeListener found in modules

1

There are 1 answers

1
Mikhail Guliaev On

This error usually happens when you add dependencies, which uses different versions of some classes under the hood, and build tool can't figure out which version of a class it have to use (in your case it's classes from com.google.android.maps:navsdk:4.3.2, com.google.android.gms:play-services-maps:17.0.0).

To get rid of this error you should consider to upgrade some of your libraries.

Note: there is a command which will help you to debug your problem: ./gradlew app:dependencies. It shows dependencies tree of a project, so you could faster detect dependencies which are used by your libraries.