Cordova android mapped to which android API - android

When using Cordova I want to build for Android API version 23.
When I do cordova platform add android then when I build the app by doing cordova build android. It builds for API 25 by default.
How do I go about setting the correct api version. Also mention what is to be installed in the Android-sdk.
Thanks

How do I go about setting the correct api version
In your config.xml, use a <preference> to set it:
<preference name="android-targetSdkVersion" value="23" />
Also mention what is to be installed in the Android-sdk
The API 23 platform SDK needs to be installed.
See the Cordova Android platform guide for more details.

Related

Android PlayStore warning your app currently targets API level 25

Warnings Your app currently targets API level 25 and must target at
least API level 26 to ensure it is built on the latest APIs optimized
for security and performance.
From August 2018, new apps must target at least Android 8.0 (API level
26). From November 2018, app updates must target Android 8.0 (API
level 26).
Tip: Change your app's target API level. Learn how.
I am using Cordova and Ionic 3.
Just built the app using: ionic cordova build android --release-prod
What should I do, ignore this or fix and how?
Thanks.
You can update your cordova-android to 7.0.0 as that's the version that uses SDK 26 as target, or you can update to cordova-android 7.1.4, as it targets SDK 27.
You can do it by removing the platform and adding it again specifying the version to use like this: (if not using ionic, remove the ionic word from both commands)
ionic cordova platform rm android
ionic cordova platform add android#7.1.4
If you don't want or can't update, you can try to set the target SDK with this preference in the config.xml
<preference name="android-targetSdkVersion" value="26"/>
And then run ionic cordova prepare
This is because Google has made it compulsory for apps to target at least 26 API level by August 2018 for new apps and November 2018 for updating apps.
Docs here.
You can do it by removing the platform and adding it again specifying the version to use like this: (if not using ionic, remove the ionic word from both commands)
ionic cordova platform rm android
ionic cordova platform add android#7.1.4
If you don't want or can't update, you can try to set the target SDK with this preference in the config.xml
And then run ionic cordova prepare
This worked for me!

How to specify the Android API version by adding in Cordova

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
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.
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/

Cordova does not "see" Android SDK version

I am in the process of setting up a new Cordova CLI toolchain to build hybrid Android apps that target Android 5.1+. I am using
Node 8.9.2
Cordova 7.1.0
After issuing a cordova create... command to create a new Cordova project I proceeded to add Android 5.1 using cordova platform add android#5.1.0 which went smoothly.
I have also ensured that I have the relevant Android SDKs available and pointed at properly via ANDROID_HOME. I currently have SDKs 19 through to 27 installed.
However, when I issue a cordova build android I get the message Error: Android SDK not found. Strangely enough if I let Cordova install its current default Android version via cordova platform add android which adds Android 6.3.1 it then lets me build the project without any further ado.
Is this a matter of Cordova 7.1.0 simply not wanting to play ball with lower versions of Android or is there something else going on here? Can I get around this by installing an older version of Cordova via npm? If so, which version should I install - and how?
Your problem is you're adding an old version of the cordova-android platform project, (v5.1.0) which is over 2 years old and not compatible with the cordova#7.1.0 CLI.
If you want to target Android 5.1+, you don't need to use cordova-android#5.1.0, you need to specify a preference in the config.xml to target Android 5.1 (API 22) and above:
<preference name="android-minSdkVersion" value="22" />
You probably want to use the default cordova-android platform version (6.3.1), unless you need to do stuff with Android Studio 3, in which case use cordova platform add android#latest which will add cordova-android#7.0.0 and requires Gradle 4 to build (see here).

Unable to change Installed platforms for android in apache cordova for visual studio

I am trying to upgrade Installed platforms to android 5.0.0 in Visual Studio Tools for Apache Cordova project by using Cordova CLI command when i run command debugg path platform will upgrade to 5.0
consol screenshot
but when i again rebuild project it reset to old version 3.7.2 , yes it will reset to older version when project build but how can i upgraded android version globally so when i build it again it show upgraded android version.
i added this in config file
<preference name="android-minSdkVersion" value="21" />
<preference name="android-targetSdkVersion" value="23" />
<preference name="android-maxSdkVersion" value="23" />
installed SDK platform for API 23 in SDK manager but still same.
From the configuration file in your Cordova app, select platform and check the checkbox to use the globally installed cordova CLI version.
This update is available if your have TACO tools update 5 in VS 2015.
Hope this helps.
From the cli run: Cordova platform add #.

How to set cordova to android target API 21

how can I set the minimum and target SDK version to 21?
So far I changed it inside the Android Manifest, but still the build process shows android SDK level 19.
Thanks
As you say it doesn't react at all to changes in the manifest, you have to manually add a tag specifying the minimum sdk in the config.xml located in the project root folder.
preference name="android-minSdkVersion" value="16"
Note that this will only work if you have updated to a Cordova version which supports the target sdk.
It is all answered here:
Changing the android target of a cordova project
With Cordova 3.5.something started to go wrong to set Cordova to android target API 21 this can be used:
<platform name="android">
<preference name="android-minSdkVersion" value="21" />
</platform>
The advantage is that now you can delete the android platform and recreate it without losing any setting.

Categories

Resources