10

I got the following error while upload my app to 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.

Here is my android/build.gradle:

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        ndkVersion = "21.4.7075529"
    }
    ...
}

How can I upgrade app target API to level 31?

Huan Huynh
  • 399
  • 6
  • 16

4 Answers4

5

I recently had this warning in my google console.

To solve it, I simply updated the targetSdkVersion from 30 to 31 in android/app/build.gradle file, which gives the following code (I also had to make sure the compileSdkVersion was set to 31):

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

    defaultConfig {
        targetSdkVersion 31
        // ... 
    }

And I had to modify the buildscript in the android/app file as below:

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'
    }
    // ...
}
Neosoulink
  • 117
  • 13
2
  <activity
    android:name=".MainActivity"
    android:exported="true" ... >

Add android:exported="true" or android:exported="false" in AndroidManifest.xml file.

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        ndkVersion = "20.1.5948944"
    }
    ...
}

change compileSdkVersion = 31 and compileSdkVersion = 31 in android/gradle/build.gradle [REACT NATIVE APPS]

1
buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        ndkVersion = "20.1.5948944"
    }
    ...
}
gildniy
  • 3,528
  • 1
  • 33
  • 23
1

I also got the same error when I deploy my application on the Play Store

so simply update the targetSdkVersion = 30 to targetSdkVersion = 31 in Your_project/android/build.gradle

targetSdkVersion = 31

and then run

cd android

./gradlew clean
Deepak Singh
  • 749
  • 4
  • 16