Cordova build for android level api 20

2019-07-28 00:01发布

I am trying to build an app made with Angular2 + Ionic2 (ie. Cordova 6) for my android 4.4.4. I have noticed the version 4.4.4 of android was reffered to the api level 20, so this is the version I have downloaded and installed (api20 + android SDK Build Tools level 20 too). In cordova I have edited the platforms/android/project.properties and platforms/android/CordovaLib/project.properties to build to android-2O instead of the default android-23 api. I have also edited the AndroidManifest.xml.

The issue comes when I try to compile my project with cordova build android, cordova executes some CordovaLib:instructions UP-TO-DATE and bug on CordovaLib:compileDebugJavaWithJavac..

According to the error report which is :

platforms/android/CordovaLib/src/org/apache/cordova/CordovaClientCertRequest.java:25: error: cannot find symbol import android.webkit.ClientCertRequest; ^ symbol: class ClientCertRequest location: package android.webkit

At the end of all the error report it also says :

You may not have the required environment or OS to build this project Error: Error code 1 for command: platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/thomas/Documents/www/MyProject/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true

So I come here to ask for help, because I have no idea what is wrong with Cordova and android-SDK...

Thank you to everyone who helps ;)

Bye !

1条回答
男人必须洒脱
2楼-- · 2019-07-28 00:18

When you build for Android there is targetSdkVersion and minSdkVersion.

targetSdkVersion indicates wich version of the API will be used to compile the program, not wich version of Android must be on the device the program will be run on.

minSdkVersion indicates the minimum version of android a device must have to be compatible with your program.

If you downgrade the targetSdkVersion, you are limited to older functions and if your program uses the newer functions it will fail to compile (I think it's what happens if you try to compile a Cordova version designed for API 23 with API 20).

By default Cordova (at least for the version 5.1 of cordova-android) uses the targetSdkVersion 23 and the minSdkVersion 14, which means programs should work on devices runing Android Ice Cream Sandwich (4.0) or newer.

In your case, all you have to do is install SDK 23 and don't touch anything to try to change the target SDK.

查看更多
登录 后发表回答