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

App crashing in upgrading targetSdk version

$
0
0

Play Store now requires that your app uses API level 28:

Both new apps and app updates must target at least Android 9 (API level 28).

Source

My app was currently using targetSdkVersion = 26 with this configuration:

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

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
        googlePlayServicesAuthVersion = "15.0.1"
        googlePlayServicesVersion = "15.0.1"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        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
    }
}

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"
        }
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
    }
}


task wrapper(type: Wrapper) {
    gradleVersion = '4.7'
    distributionUrl = distributionUrl.replace("bin", "all")
}

/**
* Project-wide gradle configuration properties for use by all modules
*/
ext {
    compileSdkVersion               = 28
    targetSdkVersion                = 28
    buildToolsVersion               = "28.0.3"
    googlePlayServicesVersion       = "12.0.1"
    googlePlayServicesVisionVersion = "15.0.2"
    supportLibVersion               = "28.0.0"
}
subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'&& !details.requested.name.contains('multidex') ) {
            details.useVersion "28.0.0"
            }
        }
    }
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 28
                buildToolsVersion '28.0.3'
            }
        }
    }
}

Trying to fix this I've changed to this:

ext {
    compileSdkVersion               = 28
    targetSdkVersion                = 28
    buildToolsVersion               = "28.0.3"
    googlePlayServicesVersion       = "12.0.1"
    googlePlayServicesVisionVersion = "15.0.2"
    supportLibVersion               = "28.0.0"
}

The app seems to run just fine in a device we have here which has Android 6.0, but in other devices like Android 9, the app crashes on the start, throwing the error bellow:

Android print

What am I doing wrong?


Viewing all articles
Browse latest Browse all 28476

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>