Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile Cordova Apps for older Android versions

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?

like image 784
TheBearF8 Avatar asked Jan 12 '18 00:01

TheBearF8


People also ask

Does Cordova support Android 12?

We have integrated the Android 12 SplashScreen API including the compatibility library into the core of the Cordova-Android platform to provide support for Android API 22+. For more information, please refer to the PR and Cordova Docs.

Does Cordova need Android studio?

Cordova-Android requires the Android SDK, which can be installed on either macOS, Linux, or Windows. For the base system requirements, see the Android Studio's System Requirements.


2 Answers

Cordova android platform version is not the same as the android version your phone needs to be runing.

A version of cordova platform supports a range of android OS versions. You can find an array of supported Android versions for each cordova android platform version on the Codova Android platform guide page.

Cordova android platform versions 6.x supported android versions from 4.1 to 7.1.

For cordova android platform version 7.x the minimum version has been set to 4.4 so platform version 7.x can't be used if you need to support phones older than Kit-Kat (the minimum sdk was changed).

All that to say that what you need is a version 6 of cordova platform tools not 4.1.1, so with the following line, it should work fine with :

cordova platform add [email protected]

I haven't tested latest version of the CLI, for the moment I'm still using cordova version 7.0.1 with android platform 6.2.3, so I'm not sure if cordova android 6.4.0 will work with cordova 8 or if you will have to downgrade also the CLI version.

like image 51
QuickFix Avatar answered Sep 18 '22 20:09

QuickFix


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]
like image 37
jcesarmobile Avatar answered Sep 21 '22 20:09

jcesarmobile