ptomasroos/react-native-idfa

Android Build failed with an exception: play-services-measurement-base

douglaswissett opened this issue · 1 comments

I recently installed this package using yarn add react-native-idfa followed by react-native link react-native-idfa

When trying to run android I'm getting this error:

> Task :app:transformClassesWithDexBuilderForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/douglaswalker/.gradle/caches/transforms-1/files-1.1/play-services-measurement-base-16.3.0.aar/e108b7e4f665f7a61dd3e8c95e4299d2/jars/classes.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 17s

I tried adding the code below to top-level build.gradle but that didn't seem to help.

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.getRequested().getGroup() == 'com.google.android.gms') {
            // If different projects require different versions of
            // Google Play Services it causes a crash on run.
            // Fix by overriding version for all projects.
            details.useVersion('17.0.0')
        }
    }
}

My app/build.gradle dependencies list looks like this:

dependencies {
    implementation project(':react-native-idfa')
    implementation project(':react-native-sound')
    implementation(project(':react-native-localize'))
    implementation 'com.android.support:multidex:1.0.3'
    implementation(project(':react-native-appsflyer'))
    implementation(project(':react-native-firebase'))
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.android.gms:play-services-base:16.0.1'
    implementation 'com.google.android.gms:play-services-stats:16.0.1'
    implementation(project(':react-native-restart'))
    implementation(project(':react-native-fs'))
    implementation(project(':react-native-linear-gradient'))
    implementation(project(':react-native-fast-image'))
    implementation(project(':react-native-audio'))
    implementation 'com.swrve.sdk.android:swrve-firebase:6.0.2'
    implementation 'com.facebook.fresco:fresco:1.10.0'
    implementation 'com.facebook.fresco:animated-gif:1.10.0'
    implementation(project(':react-native-webview'))
    implementation(project(':react-native-image-crop-picker'))
    implementation(project(':react-native-device-info'))
    implementation(project(':react-native-splash-screen'))
    implementation(project(':react-native-config'))
    implementation(project(':react-native-auth0'))
    implementation(project(':react-native-gesture-handler'))
    implementation(project(':react-native-vector-icons'))
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.android.support:support-v4:27.1.1"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

and top-level build.gradle looks like this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.1'
    }
}

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 18
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.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 {
        mavenLocal()
        google()
        jcenter()
        jcenter{
            url = 'https://dl.bintray.com/swrve-inc/android'
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven { url "https://jitpack.io" }
    }
}

Has anyone fixed this issue and can help me out?

Thanks in advance!

Edit:

Looks like excluding the group from dependency causing version conflict solved my issue.

    implementation (project(':react-native-advertising-id')) {
        exclude  group:'com.google.android.gms'
    }

Android now builds successfully!

The same issue for me.
I've replaced compile project(':react-native-idfa') with

compile (project(':react-native-idfa')) {
    exclude group:'com.google.android.gms'
}

and now it works.