cordova android updating compileSDK version

Viewed 10478

I'm new to android application building using cordova-android.

I'm facing issue when updating compileSdkVersion/buildToolsVersion in config.xml of project root directory.

As cordova-android version-9 support api level 29 but as Android SDK API level 30 is available and cordova-android still not provided support yet.

I tried updating preferences compileSdkVersion/buildToolsVersion like below in config.xml

<?xml version='1.0' encoding='utf-8'?>
My first app Test application Your Name Here

Can someone help me in updating above two properties, so that apk can be build with latest SDK API level 30.

2 Answers

Based on Cordova requirements and support, current cordova-android@9 supports API level 29 and below. We can expect that next version cordova-android@10 will likely to target API level 30 and may need to wait for an official update from Cordova team. enter image description here

Until then we can play around with the nightly version of cordova-android@10 from npm

According to the recent deadlines from Google,

August 2021 - New apps must target at least Android 11 (API level 30)

November 2021 - Existing apps must target at least Android 11 (API level 30) for new app updates

So we can wait till August for an official update :).

Workaround :
(may or may not work. Use it in a sample application before implementing in the real application)

Change android-targetSdkVersion on config.xml

<preference name="android-targetSdkVersion" value="30" />

Remove the platform by using

cordova platform remove android

then add the latest cordova android version :

cordova platform add android@latest

Build the project :

cordova build android

In your config.xml add / update targetSdk version to 30 like below.

<preference name="android-targetSdkVersion" value="30" />

Above command will change targetSdk version to 30

Remove platform android and add back with below command

cordova platform add android@10.0.0

Above command will update compileSdk version to 30. If this step isn't done it will give same value as whatever version was available when you added platform.

Also make sure you have latest sdk and build tool is installed for proper command execution.

Related