3

I was trying to build an Android project on react-native application. Everything was working correctly until this morning. It is strange since no code was changed but build is failing. It could be something to do with internal dependency update but I was unable to figure it out.

I was trying to update compileSdkVersion to 28 but this produces more problems and I would like to avoid it if it was not completely necessary.

android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 21
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
        googlePlayServicesAuthVersion = "15.0.1"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:4.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

android/app/build.gradle

dependencies {
    // this is copied from
    implementation('com.onesignal:OneSignal:3.10.8') {
        // Exclude com.android.support(Android Support library) as the version range starts at 26.0.0
        //    This is due to compileSdkVersion defaulting to 23 which cant' be lower than the support library version
        //    And the fact that the default root project is missing the Google Maven repo required to pull down 26.0.0+
        exclude group: 'com.android.support'
        // Keeping com.google.android.gms(Google Play services library) as this version range starts at 10.2.1
    }
    implementation project(':react-native-onesignal')
    implementation project(':appcenter')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-reanimated')
    implementation project(':react-native-audio-jack')
    implementation project(':react-native-firebase')
    androidTestImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test:rules:1.0.1'
    implementation project(':appcenter-crashes')
    implementation project(':appcenter-analytics')

    implementation project(':react-native-heading')
    implementation project(':react-native-billing')
    implementation project(':react-native-android-badge')
    implementation project(':react-native-sound')
    implementation project(':react-native-google-analytics-bridge')
    implementation project(':react-native-bluetooth-state')
    implementation project(':react-native-code-push')
    implementation (project(':@mapbox_react-native-mapbox-gl')){
        implementation ('com.squareup.okhttp3:okhttp:3.9.1') {
            force = true
        }
    }
    implementation project(':react-native-kontaktio')
    implementation project(':realm')
    implementation project(':rn-fetch-blob')
    implementation project(':react-native-restart')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-keep-awake')
    implementation project(':react-native-image-crop-picker')
    implementation project(':react-native-i18n')
    implementation project(':react-native-fs')
    implementation project(':react-native-exception-handler')
    implementation project(':react-native-device-info')
    implementation (project(':react-native-camera')){
        exclude group: "com.android.support"
    }
    implementation project(':react-native-android-location-services-dialog-box')
    implementation project(':lottie-react-native')
    implementation project(':react-native-google-signin')
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-config')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation "com.google.firebase:firebase-invites:16.1.0"
}

I expect Android build to pass without errors.

2 Answers 2

4

It seems to be related to Google releasing a new version of their Play Service and as you don't want to update compileSdkVersion.

try this:

implementation(project(":react-native-device-info"),  {
  exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-gcm:16.0.0"

for more and detailed info, you can refer this

Sign up to request clarification or add additional context in comments.

2 Comments

This was a solution! At least a step in the right direction. I needed to find all dependancies that has "com.google.android.gms:+" in their build.gradle and exclude their "exclude group: 'com.google.android.gms'" from our android/app/build.gradle to force "com.google.android.gms:play-services-gcm:16.1.0" version.
@aleksander thanks for input. I have a strong feeling I will end up doing the same. Is there any way you could show me what your changes look like? It would help me incredibly much
1

Add below line of code in root level build.gradle file

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 28
                buildToolsVersion '28.0.1'
            }
        }

    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.