0

Trying to build my react native project after adding React-native-firebase to the application is causing it to fail to build the application. I am getting the following error:

* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.google.android.gms:play-services-measurement-api:9.8.0.
  Searched in the following locations:
      file:/Users/cliffc/Library/Android/sdk/extras/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      file:/Users/cliffc/Library/Android/sdk/extras/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      file:/Users/cliffc/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      file:/Users/cliffc/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      file:/Users/cliffc/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      file:/Users/cliffc/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      file:/Users/cliffc/.m2/repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      file:/Users/cliffc/.m2/repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      https://repo.maven.apache.org/maven2/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      https://repo.maven.apache.org/maven2/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      file:/Users/cliffc/projects/prod/commconn/cc/node_modules/react-native/android/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      file:/Users/cliffc/projects/prod/commconn/cc/node_modules/react-native/android/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      https://maven.google.com/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      https://maven.google.com/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      https://jitpack.io/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      https://jitpack.io/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
  Required by:
      project :app > com.google.firebase:firebase-core:16.0.3 > com.google.firebase:firebase-measurement-connector-impl:17.0.1
      project :app > com.google.android.gms:play-services:9.8.0 > com.google.firebase:firebase-analytics:16.0.3

this is only one of them I get the same error for the following services:

Could not find com.google.android.gms:play-services-measurement-base:9.8.0.
Could not find com.google.android.gms:play-services-stats:9.8.0.
Could not find com.google.android.gms:play-services-ads-identifier:9.8.0.

My MainApplication get packages are:

protected List<ReactPackage> getPackages() {
    // Add additional packages you require here
    // No need to add RnnPackage and MainReactPackage
    mCallbackManager = new CallbackManager.Factory().create();
    return Arrays.<ReactPackage>asList(new MapsPackage(), new RNDeviceInfo(), new FBSDKPackage(mCallbackManager),
        new PickerPackage(), new RNFetchBlobPackage(), new VectorIconsPackage(),
        new ReactNativePushNotificationPackage(), new RNFirebasePackage());
    // eg. new VectorIconsPackage()
  }

Build.gradle (app):

ext {
    compileSdkVersion   = 27
    targetSdkVersion    = 27
    buildToolsVersion   = "27.0.1"
    supportLibVersion   = "26.1.0"
    googlePlayServicesVersion = "15.0.1"
    androidMapsUtilsVersion = "0.5+"
    firebaseVersion = "+"
}

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.1"

    defaultConfig {
        applicationId "com.commonconnectapp"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 22
        versionName "1.0.1"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.getRequested().getGroup() == 'com.google.android.gms') {
            details.useVersion('9.8.0')
        }
    }
}

dependencies {
    compile project(':react-native-firebase')
   compile project(':react-native-push-notification')
    compile project(':react-native-maps')
    compile project(':react-native-image-picker')
    compile project(':react-native-fbsdk')
    compile project(':rn-fetch-blob')
    compile project(':react-native-vector-icons')
    compile project(':react-native-image-crop-picker')
    compile project(':react-native-device-info')
    compile fileTree(dir: "libs", include: ["*.jar"])
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support:multidex:1.0.3'
    // compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    implementation project(':react-native-maps')
    compile project(':react-native-navigation')
    implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-firebase')
    implementation "com.google.firebase:firebase-core:16.0.3"
    compile "com.google.android.gms:play-services:15.0.1"
}

thank you in advanced for any help. If any more info is needed please let me know. I've been searching and tried some fixes to no avail. I'll keep researching and add the answer myself if I find it.

1 Answers1

0

Something like that happened to me before. When you are installing native dependencies like that, in android studio you'll see different projects besides your main react native application.

One of these projects should be react native firebase if you installed it propertly. Well, thia project, same as your main application project, has also a gradle file with dependencies.

Check if there the library the error specifies is there and it's the same version as your gms services in your main application.