Arun Wilson
Arun Wilson

Reputation: 181

react-native-firebase implementation is not possible in existing project ( [email protected] ). gradle build failed

I tried to implement firebase in my existing react-native project, and the gradle build failed.

But implemented on a new project ([email protected]) without any trouble, I'm not good in android, So can't figured out what's the issue in project setup.

Main errors in gradle build

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.

gradle build full error:

**> Task :react-native-fast-image:processDebugManifest 
/var/www/html/travalour/react-native-app/node_modules/react-native-fast-image/android/src/main/AndroidManifest.xml:11:9-15:15 Warning:
        meta-data#com.bumptech.glide.integration.okhttp.OkHttpGlideModule was tagged at AndroidManifest.xml:11 to remove other declarations but no other declaration present


FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.google.android.gms:play-services-measurement-base:9.8.0.
  Searched in the following locations:
      file:/home/cyberinfoscripter/Android/Sdk/extras/m2repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/m2repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
      file:/home/cyberinfoscripter/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
      file:/home/cyberinfoscripter/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
      file:/home/cyberinfoscripter/.m2/repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      file:/home/cyberinfoscripter/.m2/repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
      https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
      file:/var/www/html/travalour/react-native-app/node_modules/react-native/android/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      file:/var/www/html/travalour/react-native-app/node_modules/react-native/android/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
  Required by:
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-analytics:16.0.1
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-measurement-connector-impl:16.0.1
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-analytics:16.0.1 > com.google.firebase:firebase-analytics-impl:16.1.1
> Could not find com.google.android.gms:play-services-stats:9.8.0.
  Searched in the following locations:
      file:/home/cyberinfoscripter/Android/Sdk/extras/m2repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/m2repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
      file:/home/cyberinfoscripter/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
      file:/home/cyberinfoscripter/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
      file:/home/cyberinfoscripter/.m2/repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      file:/home/cyberinfoscripter/.m2/repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
      https://jcenter.bintray.com/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      https://jcenter.bintray.com/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
      file:/var/www/html/travalour/react-native-app/node_modules/react-native/android/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      file:/var/www/html/travalour/react-native-app/node_modules/react-native/android/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
  Required by:
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-analytics:16.0.1
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-analytics:16.0.1 > com.google.firebase:firebase-analytics-impl:16.1.1
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-analytics:16.0.1 > com.google.firebase:firebase-analytics-impl:16.1.1 > com.google.firebase:firebase-iid:16.0.0
> Could not find com.google.android.gms:play-services-ads-identifier:9.8.0.
  Searched in the following locations:
      file:/home/cyberinfoscripter/Android/Sdk/extras/m2repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/m2repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
      file:/home/cyberinfoscripter/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
      file:/home/cyberinfoscripter/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
      file:/home/cyberinfoscripter/.m2/repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      file:/home/cyberinfoscripter/.m2/repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
      https://jcenter.bintray.com/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      https://jcenter.bintray.com/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
      file:/var/www/html/travalour/react-native-app/node_modules/react-native/android/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      file:/var/www/html/travalour/react-native-app/node_modules/react-native/android/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
  Required by:
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-analytics:16.0.1 > com.google.firebase:firebase-analytics-impl:16.1.1

* 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 14s
24 actionable tasks: 24 executed
**

'android/build.gradle' file

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

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        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()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }

    }
}

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "26.1.0"
            }
        }
    }
}

'android/app/build.gradle' file

apply plugin: "com.android.application"
project.ext.envConfigFiles = [
    debug: ".env.development",
    release: ".env.production",
    anothercustombuild: ".env",
]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

import com.android.build.OutputFile

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

apply from: "../../node_modules/react-native/react.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 26
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.travalour"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        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
            }
        }
    }
}

//added the configurations.all for making the map work
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.getRequested().getGroup() == 'com.google.android.gms') {
            details.useVersion('9.8.0')
        }
    }
}

dependencies {
    implementation project(':react-native-firebase')
    // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:15.0.1"
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation project(':react-native-fast-image')
    implementation project(':realm')
    implementation project(':react-native-google-signin')
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-fetch-blob')
    implementation project(':react-native-config')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-video')
    implementation project(':react-native-device-info')
    implementation project(':realm')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:23.0.1"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    implementation 'com.google.android.gms:play-services-maps:10.0.1'
    implementation('com.facebook.android:facebook-android-sdk:[4,5)')
}

// 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 plugin: 'com.google.gms.google-services'

'android/settings.gradle' file

rootProject.name = 'Travalour'
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':react-native-fast-image'
project(':react-native-fast-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fast-image/android')
include ':react-native-fetch-blob'
project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')
include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')
include ':react-native-google-signin'
project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-signin/android')
include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':realm'
project(':realm').projectDir = new File(rootProject.projectDir, '../node_modules/realm/android')
include ':app'
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')

distributionUrl value in 'gradle-wrapper.properties' is https\://services.gradle.org/distributions/gradle-4.4-all.zip

Node modules installed :

+-- @expo/[email protected]
+-- @expo/[email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- UNMET PEER DEPENDENCY expo@>=22.0.0
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- UNMET PEER DEPENDENCY [email protected]
+-- UNMET PEER DEPENDENCY react-dom@*
+-- UNMET PEER DEPENDENCY [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
-- [email protected]

Upvotes: 1

Views: 1066

Answers (1)

Anders Ekman
Anders Ekman

Reputation: 321

In your android/app/build.gradle you need to remove:

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

Also update your dependencies to this:

dependencies {
    implementation project(':react-native-firebase')
    // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:16.0.1"
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation project(':react-native-fast-image')
    implementation project(':realm')
    implementation project(':react-native-google-signin')
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-fetch-blob')
    implementation project(':react-native-config')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-video')
    implementation project(':react-native-device-info')
    implementation project(':realm')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:23.0.1"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    implementation 'com.google.android.gms:play-services-maps:16.0.1'
    implementation('com.facebook.android:facebook-android-sdk:[4,5)')
}

Your google dependencies should all use the same version.

Upvotes: 1

Related Questions