Google-signin: Build error when multiDexEnabled true in android/app/build.gradle

Created on 16 Oct 2019  路  3Comments  路  Source: react-native-google-signin/google-signin

App build for Android fails when "multiDexEnabled true" in android/app/build.gradle

Steps to Reproduce

Set multiDexEnabled true in android/app/build.gradle

android {
defaultConfig {
...
multiDexEnabled true
}
}

Run: npx react-native run-android

You can find an example rep here:

https://github.com/serbanstef/googlesignintest

Note that it is just a fresh RN project initialisation (react-native init ) with react-native-google-signin installed following your instructions for RN > 0.60

  • Explain the steps we need to take to reproduce the issue.

The issue should be reproducible on any RN project (including an empty/new one) with react-native-google-signin > 3.0.0 installed.

Just enable multiDexEnabled true in android/app/build.gradle as showed above and run npx react-native run-android

Expected Behavior

Build successful.

Actual Behavior

Build fails with:

Task :app:transformClassesWithMultidexlistForDebug FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
    > com.android.build.api.transform.TransformException: Error while generating the main dex list:
    Error while merging dex archives:
    Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
    Program type already present: co.apptailor.googlesignin.BuildConfig

or sometimes

Program type already present: co.apptailor.googlesignin.PendingAuthRecovery

Environment

react-native version 0.61.2
@react-native-community/google-signin version 3.0.1
Gradle 5.5
googlePlayServicesAuthVersion = "16.0.1"

Most helpful comment

hi, thanks for including a repro. The conflict probably happens because of CLI performing autolinking.

Please try removing occurrences of "react-native-google-signin" from android/app/build.gradle and android/settings.gradle. Take a look at the example files: 1 2.

Also, you may need to add implementation 'com.android.support:multidex:1.0.3' (https://developer.android.com/studio/build/multidex#mdex-gradle).

All 3 comments

hi, thanks for including a repro. The conflict probably happens because of CLI performing autolinking.

Please try removing occurrences of "react-native-google-signin" from android/app/build.gradle and android/settings.gradle. Take a look at the example files: 1 2.

Also, you may need to add implementation 'com.android.support:multidex:1.0.3' (https://developer.android.com/studio/build/multidex#mdex-gradle).

Thanks Vojtek. it worked.

hi, thanks for including a repro. The conflict probably happens because of CLI performing autolinking.

Please try removing occurrences of "react-native-google-signin" from android/app/build.gradle and android/settings.gradle. Take a look at the example files: 1 2.

Also, you may need to add implementation 'com.android.support:multidex:1.0.3' (https://developer.android.com/studio/build/multidex#mdex-gradle).

work for me thanks.

Was this page helpful?
0 / 5 - 0 ratings