react-native-background-geolocation: Cannot change artifacts of configuration ':@mauron85_react-native-background-geolocation:default' after it has been included in dependency resolution.

Error after add react-native-onesignal and run ./gradlew clean or react-native run-android please help for fix this error thanks `FAILURE: Build failed with an exception.

Cannot change artifacts of configuration ‘:@mauron85_react-native-background-geolocation:default’ after it has been included in dependency resolution.`

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 8
  • Comments: 19

Most upvoted comments

Strange. 0.6.3 wasnt working for me either but after downgrading to 0.5.6, it works fine. I can’t help you how i made it work (because i don’t know), i’m new at android. Doesn’t work on iOS

"react-native": "0.61.4",
"@mauron85/react-native-background-geolocation": "0.5.6",
"react-native-onesignal": "^3.5.0",

After two hours, this works.

I was using react-native-firebase for storage, react-native-onesignal for push notifications and this library for geolocation features.

At first, I commented this line from my app/build.gradle

// apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

Add following lines at the bottom

apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

Dependencies section from that same file are:

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.android.support:multidex:1.0.0"

    implementation project(':react-native-firebase')
    implementation project(':react-native-navigation')
    implementation project(':@mauron85_react-native-background-geolocation')
    implementation project(':react-native-onesignal')
    implementation project(':react-native-splash-screen')

    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation "com.google.android.gms:play-services-location:15.0.1"

    implementation "com.google.firebase:firebase-core:16.0.9"
    implementation "com.google.firebase:firebase-messaging:18.0.0"
    implementation "com.google.firebase:firebase-analytics:17.0.0"
    implementation "com.google.firebase:firebase-storage:17.0.0"

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

My build.gradle file (at the root, not from app/ folder):

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

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 18
        compileSdkVersion = 28
        targetSdkVersion = 28

        supportLibVersion = "28.0.0"
        googlePlayServicesVersion = "11+"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.2")
        classpath 'com.google.gms:google-services:4.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenLocal()
        mavenCentral()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        maven { url 'https://jitpack.io' }
    }
}

subprojects { subproject ->
    afterEvaluate {
        if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion

                variantFilter { variant ->
                    def names = variant.flavors*.name
                    if (
                            names.contains("reactNative51") ||
                            names.contains("reactNative55") ||
                            names.contains("reactNative56") ||
                            names.contains("reactNative57") ||
                            names.contains("reactNative57_5")
                    ) {
                        setIgnore(true)
                    }
                }
            }
        }
    }
}

Finally, my versions from the package json:

"@mauron85/react-native-background-geolocation": "^0.6.3",
"react-native-onesignal": "^3.6.1",
"react-native-firebase": "^5.6.0"

Hope to help someone. Cheers!

If your project run for company, I suggest you to buy this lib https://github.com/transistorsoft/react-native-background-geolocation. Because this library won’t help you. Sorry for that

// apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

Only comments this line solve my problem, please, close this issue

Fixed & Tested!! remove following line from your app/build.gradle -> apply plugin: ‘com.onesignal.androidsdk.onesignal-gradle-plugin’

This is required only if you run into any issues with duplicate classes. i found it in onesignal build.gradle file

Strange. 0.6.3 wasnt working for me either but after downgrading to 0.5.6, it works fine. I can’t help you how i made it work (because i don’t know), i’m new at android.

"react-native": "0.61.4",
"@mauron85/react-native-background-geolocation": "0.5.6",
"react-native-onesignal": "^3.5.0",

this solution not work on IOS