升级targetSdk版本应用崩溃
App crashing in upgrading targetSdk version
Play 商店现在要求您的应用使用 API 级别 28:
Both new apps and app updates must target at least Android 9 (API level 28).
我的应用当前使用的是 targetSdkVersion = 26
此配置:
// 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'
}
}
}
}
试图解决这个问题,我已更改为:
ext {
compileSdkVersion = 28
targetSdkVersion = 28
buildToolsVersion = "28.0.3"
googlePlayServicesVersion = "12.0.1"
googlePlayServicesVisionVersion = "15.0.2"
supportLibVersion = "28.0.0"
}
该应用似乎 运行 在我们这里的 Android 6.0 设备上运行良好,但在 Android 9 等其他设备上,该应用在启动时崩溃,抛出以下错误:
我做错了什么?
请按照以下命令操作:
1. cd android/ && ./gradlew clean && cd ..
2. react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
3. react-native run-android
如果仍然遇到同样的问题,请告诉我
Play 商店现在要求您的应用使用 API 级别 28:
Both new apps and app updates must target at least Android 9 (API level 28).
我的应用当前使用的是 targetSdkVersion = 26
此配置:
// 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'
}
}
}
}
试图解决这个问题,我已更改为:
ext {
compileSdkVersion = 28
targetSdkVersion = 28
buildToolsVersion = "28.0.3"
googlePlayServicesVersion = "12.0.1"
googlePlayServicesVisionVersion = "15.0.2"
supportLibVersion = "28.0.0"
}
该应用似乎 运行 在我们这里的 Android 6.0 设备上运行良好,但在 Android 9 等其他设备上,该应用在启动时崩溃,抛出以下错误:
我做错了什么?
请按照以下命令操作:
1. cd android/ && ./gradlew clean && cd ..
2. react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
3. react-native run-android
如果仍然遇到同样的问题,请告诉我