Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28469

React native Build failed as "Could not find com.google.android.gms:play-services-ads-identifier:12.0.1"

$
0
0

I am trying to build my react native app with react-native run-android command. But the build is failing with the below error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':react-native-onesignal:debugComp                                                                                                                ileClasspath'.
> Could not find com.google.android.gms:play-services-ads-identifier:12.0.1.
  Required by:
      project :react-native-onesignal > com.onesignal:OneSignal:3.12.2

I searched online for a solution and most of the post says to move the google dependency before jcenter() for android/build.gradle file. So, I followed the same as you can see from the code shared below but still the build is failing with the same error. Anyone have faced similar issue?

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.0'
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:3.1.1'

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

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

        maven {
            // Local Maven repo containing AARs with JSC library built for Android
            url "$rootDir/../node_modules/jsc-android/dist"
        }
    }

    configurations.all {
        resolutionStrategy {
            force 'com.facebook.android:facebook-android-sdk:4.34.0'
        }
    }

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

                if (details.requested.group == 'com.google.firebase') {
                    details.useVersion '12.0.1'
                }
            }
        }
        afterEvaluate {project ->
            if (project.hasProperty("android")) {
                android {
                    compileSdkVersion 27
                    buildToolsVersion "27.0.3"
                }
            }
        }
    }
}

Viewing all articles
Browse latest Browse all 28469

Trending Articles