简体   繁体   English

具有特定版本的“cordova 添加平台 android”

[英]'cordova add platform android' with specific version

I want add android platform on cordova using specific version: android-10.我想使用特定版本在cordova上添加android平台:android-10。 I use 'gulp' with 'gulp-shell' to create cordova env, so it must be repeatable in command line for CI and CD.我使用'gulp'和'gulp-shell'来创建cordova env,所以它必须在命令行中为CI和CD重复。

Today when I run:今天我跑步时:

$ cordova platforms add android

It create in platforms/android/AndroidManifest.xml file :它在platforms/android/AndroidManifest.xml文件中创建:

android:minSdkVersion="10" android:targetSdkVersion="19"

I want android:minSdkVersion="14" android:targetSdkVersion="19"我想要android:minSdkVersion="14" android:targetSdkVersion="19"

Try to check here what is the list of Android Platforms => Cordova Android Platforms尝试在这里检查什么是 Android 平台列表 => Cordova Android 平台

and try to use:并尝试使用:

cordova platform add android@x.x.x

replacing xxx with the version that you need将 xxx 替换为您需要的版本

A list of released version can be found on github .可以在 github 上找到已发布版本的列表

In your cordova project's config.xml, add an android platform section:在您的 cordova 项目的 config.xml 中,添加一个 android 平台部分:

<platform name="android">
    <preference name="android-minSdkVersion" value="14" />
</platform>

This way each time you build, it will get added to the android manifest, instead of getting overwritten each time you rebuild.这样每次构建时,它都会被添加到 android 清单中,而不是每次构建时都被覆盖。

If you want to target a newer platform than 19, then you can use a second preference:如果您想定位比 19 更新的平台,那么您可以使用第二个首选项:

<preference name="android-targetSdkVersion" value="22" />

Cheers!干杯!

A trick if you don't known which xxx release is available, request only the master version.如果您不知道哪个 xxx 版本可用,请只请求主版本。 Eg :例如:

cordova add platform android@4

, will install the next available 4.xx release. ,将安装下一个可用的 4.xx 版本。 today 4.1.1.今天4.1.1。

Enjoy享受

Bruno布鲁诺

The command to add a specific version of android platform via cordova is:通过cordova添加特定版本的android平台的命令是:

 cordova platform add android@VERSION

eg.例如。

cordova platform add android@8

Change the AndroidManifest.xml maually.手动更改AndroidManifest.xml Open that file in any editor.在任何编辑器中打开该文件。 Then set your choices.然后设置你的选择。

android:minSdkVersion="14" android:targetSdkVersion="19"

And build the project并构建项目

$ cordova build android

Goal目标

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM