How can I set the target Android SDK for Cordova?

Viewed 1404

For a new Cordova project, I want to add Android as a platform using

cordova platform add android

And I want to use Android version 16. So I set these properties in the config.xml

<preference name="android-minSdkVersion" value="16" />
<preference name="android-targetSdkVersion" value="16" />

And I run

cordova platform add android --target android-16

Yet what I see in the logging is

Using cordova-fetch for cordova-android@~6.3.0
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: io.cordova.hellocordova
        Name: HelloCordova
        Activity: MainActivity
        Android target: android-26

So it still targets Android 26 instead of 16. Indeed, when I run cordova build, it builds using Android version 26. Why is that? What can I do to fix this?

1 Answers

The syntax you use to provide android version is wrong.

Instead of

cordova platform add android --target android-16

it should be

cordova platform add android@16
Related