S.Hashmi
S.Hashmi

Reputation: 501

Having Could not determine the dependencies issue in React Native Android

I am integrating firebase in android and having issues regrading android dependencies. When i add dependencies in root build.gradle file like this ...

implementation 'com.google.android.gms:play-services-base:16+'
    implementation 'com.google.firebase:firebase-core:17.2.0'

Having this issue...

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':react-native-firebase:compileDebugAidl'.
> The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[17.2.0,17.2.0]], but resolves to 16.5.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

Please help regarding this issue

app/build.gradle

dependencies {
    implementation project(':react-native-firebase')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.google.android.gms:play-services-base:16+'
    implementation 'com.google.firebase:firebase-core:17.2.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
    }
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'

Android level build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
 classpath 'com.android.tools.build:gradle:3.3.0'
  classpath 'com.google.gms:google-services:4.0.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenLocal()
        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")
        }

        jcenter()
        maven { url 'https://jitpack.io' }
           maven {
            url 'https://maven.google.com'
        }
    }
}

Here is package.json file

{
  "name": "",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "react": "16.9.0",
    "react-native": "0.61.2",
    "react-native-firebase": "^5.5.6"
  },
  "devDependencies": {
    "@babel/core": "7.6.4",
    "@babel/runtime": "7.6.3",
    "@react-native-community/eslint-config": "0.0.3",
    "babel-jest": "24.9.0",
    "eslint": "6.5.1",
    "jest": "24.9.0",
    "metro-react-native-babel-preset": "0.51.1",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

Upvotes: 0

Views: 2294

Answers (1)

Harry Moreno
Harry Moreno

Reputation: 11673

in my case we had two entries for

// android/app/build.gradle
implementation project(':react-native-firebase')
...
implementation project(':react-native-firebase')

and so the gradle wasn't sure which to use. Solution is to only list the dependency once.

Upvotes: 1

Related Questions