java – Getting duplicate class error when integrating Firebase Cloud Messaging-ThrowExceptions

Exception or error:

We’re fairly new to android app development and we couldn’t figure out this error. As we are trying to put a server push notification on top of our indoor mapping service app and we stumbled to this error.

We used two APIs from our build which is Google Map API and AnyPlace API (our indoor information service that allows us to incorporate floor plan on top of the OSM layer of the building), if any of that helps.

If still this lack information to sort the problem, please let us know and we would give the needed details. So any help is very much appreciated!

Duplicate class com.google.android.gms.ads.identifier.AdvertisingIdClient found in modules classes.jar (com.google.android.gms:play-services-ads-identifier:15.0.1) and google-play-services.jar (google-play-services.jar)

Top Gradle

buildscript {
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.5.1'
    classpath 'com.google.gms:google-services:4.0.1'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}
allprojects {
repositories {
    google()
    jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

App Gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {

compileSdkVersion 27
sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    // Move the build types to build-types/<type>
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
    // This moves them out of them default location under src/<type>/... which would
    // conflict with src/ being used by the main source set.
    // Adding new build types or product flavors should be accompanied
    // by a similar customization.
    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
}

buildTypes {
    debug {
        debuggable = true
    }
}
lintOptions {
    abortOnError false
}
defaultConfig {
    targetSdkVersion 27
    minSdkVersion 16
}
dependencies {
implementation fileTree(include: '*.jar', dir: 'libs')

implementation project(':library')
implementation project(':actionbarsherlock')
implementation  ('com.google.firebase:firebase-core:16.0.1')
implementation ('com.google.firebase:firebase-messaging:17.3.4')
}
}
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *