How to compile Cordova Apps for older Android versions

TheBearF8 picture TheBearF8 · Jan 12, 2018 · Viewed 11.8k times · Source

I have installed cordova-android version 7.0.0

My app must run in Android 4.1.1

So I added the platform with:

cordova platform add [email protected]

Then I get:

Using cordova-fetch for [email protected] Adding android project... Unable to load PlatformApi from platform. Error: Unhandled "error" event. (Does not appear to implement platform Api.) Error: Package name must look like: com.company.Name

Any advice?

Answer

jcesarmobile picture jcesarmobile · Mar 7, 2018

The original question has been edited and it ask for Android 4.1.1 (SDK 16) support now and not SDK 19 as the original answer.

To support Android 4.1.1 you can use cordova-android 7.0.0 or older, cordova-android 7.1.0 increased the Min SDK to 19.

ORIGINAL ANSWER:

First of all, even latest cordova-android version (7.1.0 at the moment), still supports SDK 19 and newer, so not sure why do you want to downgrade to 4.1.1.

Now, to get cordova-android 4.1.1 working you need an old Cordova CLI, because new CLIs require new platforms and are not compatible with very old one such as 4.1.1.

So install Cordova CLI 5.4.1 with

npm install -g [email protected]

After doing that, you should be able to add cordova-android 4.1.1 with

cordova platform add [email protected]