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
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 ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.