React Native - 上传到 Google Play 错误:您的应用当前目标 API 级别 30,并且必须至少定位 API 级别 31

Hua*_*ynh 10 google-play react-native android-api-levels

将我的应用程序上传到 Google 时出现以下错误:

Your app currently targets API level 30 and must target at least API level 31 to ensure it is built on the latest APIs optimized for security and performance. Change your app's target API level to at least 31.
Run Code Online (Sandbox Code Playgroud)

这是我的android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        ndkVersion = "21.4.7075529"
    }
    ...
}
Run Code Online (Sandbox Code Playgroud)

如何将应用程序目标 API 升级到级别 31?

Neo*_*ink 5

我最近在我的谷歌控制台中收到了这个警告。

为了解决这个问题,我只需将文件targetSdkVersion中的 30 更新为 31 android/app/build.gradle,这给出了以下代码(我还必须确保将其compileSdkVersion设置为31):

android {
    compileSdkVersion 31 // You can use 
    //...

    defaultConfig {
        targetSdkVersion 31
        // ... 
    }
Run Code Online (Sandbox Code Playgroud)

我必须修改文件buildscript中的内容android/app,如下所示:

buildscript {
    ext {
        buildToolsVersion = '30.0.2'
        minSdkVersion = 21
        compileSdkVersion = 31 // You can use ``rootProject.ext.compileSdkVersion`` instead
        targetSdkVersion = // You can use ``rootProject.ext.targetSdkVersion`` instead
        ndkVersion = '21.4.7075529'
        playServicesVersion = '17.0.0' // or find latest version
        androidMapsUtilsVersion = '2.3.0'
    }
    // ...
}
Run Code Online (Sandbox Code Playgroud)


gil*_*niy 1

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        ndkVersion = "20.1.5948944"
    }
    ...
}
Run Code Online (Sandbox Code Playgroud)