3

After creating a mobile-first Cordova project with the command:

cordova create cordovatest1 com.sample.cordova cordovatest1 --template cordova-template-mfp

I add the Android platform to the project with the command:

cordova platform add android

the question is why the Android version for the platform which was just added takes the Android API 23 / android version 5.1.1, even I have already other API levels: 22, 25, 27 in SDK manager?

is there a config file belong to Cordova says that the Android platform must be for example android-23 if the developer didn't specify the Android version by adding like

cordova platform add android@6.1.2

or maybe the mobilefirst-cli witch is already installed under the version 8.0.0 force that adding platforms?

This screenshot can give you more details

enter image description here

Heni
  • 156
  • 3
  • 12

2 Answers2

2

This is unrelated to IBM MobileFirstPlatform SDK plugin. The Android target is determined by your Cordova version.

For example, cordova-android@6.1.2 targets Android API Level 25. cordova-android@6.3.0 targets Android API Level 26.

Details here.

You have not mentioned your Cordova CLI version. Since you see cordova-android@5.1.1 being added, it seems to be Cordova CLI version 6.0.

The results would be the same if you were to create a blank Cordova project ( without cordova-template-mfp) and then add platform.

Vivin K
  • 2,681
  • 1
  • 11
  • 14
  • Where i can changed if it's related to Cordova version, thanks – Heni Apr 07 '18 at 08:16
  • 1
    You can mention it specifically when adding the platform: cordova platform add android@6.3.0 or cordova platform add android@6.1.2 – Vivin K Apr 08 '18 at 10:29
  • you didn't understand what I mean, I don't want to add the Android platform version explicitly, the question is, why when we run the cmd for adding the Android platform to cordova base project we got the andoird verson 5.1.1 and not 6.1.2 – Heni Apr 08 '18 at 13:39
  • 1
    I do not think you understood the explanation. The default version of Android is determined by the version of Cordova CLI you have installed. Upgrade your Cordova CLI if you want a higher version of cordova-android added by default – Vivin K Apr 09 '18 at 09:37
  • Because you have saved Android 5.1.1 in npm-cache. Check npm-cache folder: C:\Users\Training\AppData\Roaming\npm-cache\cordova-android – Gaurab Kumar Apr 10 '18 at 16:30
1

why the Android version for the platform which was just added takes the Android API 23 / android version 5.1.1

Because you have saved Android 5.1.1 in npm-cache.

Check npm-cache folder: C:\Users\Training\AppData\Roaming\npm-cache\cordova-android

Currently the Cordova android platform versions supported by the MobileFirst plug-ins, is:

cordova-android: >= 6.1.2 and < 9.0

Try using these command:

To upgrade:

cordova platform update android@9.0

To add it explicitly:

cordova platform remove android
cordova platform add android@9.0

or

cordova platform add android@latest

For more details see here : https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/application-development/sdk/cordova/

Gaurab Kumar
  • 2,144
  • 2
  • 17
  • 29
  • 1
    Now with latest ifix onwards MobileFirst Plugins support Cordova 8 and Cordova Android 7 as well.More details see here https://mobilefirstplatform.ibmcloud.com/blog/2018/04/09/8-0-ifix-release/ – manjunath kallannavar Apr 10 '18 at 05:21