Action required: Update your Android targetSdkVersion by Nov 2, 2020

Dear Friends,

I am trying to update target SDK version 29 using cordova android platform 9.0.0

ionic cordova platform add android@9.0.0

But it’s getting me error like,

> cordova.cmd platform add android@9.0.0
Using cordova-fetch for cordova-android@9.0.0
Adding android project...
Unable to load PlatformApi from platform. SyntaxError: Unexpected token {
Unhandled "error" event. (The platform "android" does not appear to be a valid cordova platform. It
is missing API.js. android not supported.)
[ERROR] An error occurred while running subprocess cordova.
        cordova.cmd platform add android@9.0.0 exited with exit code 1.
        Re-running this command with the --verbose flag may provide more information.

Can you please help on this?

I want to udpate SDK version 29 or higher.

Best Regards!

  1. add android platform like this:

ionic cordova platform add android

  1. after downloaded android platform go to:
    Platforms --> android --> build.gradle then go to the bottom of the build.gradle page, and you will find something like this:
project.ext {
          defaultBuildToolsVersion="28.0.3" //String
          defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
          defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
         defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default
    }
  1. change the code:
project.ext {
          defaultBuildToolsVersion="29" //String
          defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
          defaultTargetSdkVersion=29 //Integer - We ALWAYS target the latest by default
         defaultCompileSdkVersion=29 //Integer - We ALWAYS compile with the latest by default
    }

then build your android.

Thank a lot @erkinalan for sharing this information and its working for me.

1 Like