简体   繁体   English

cordova android 更新compileSDK版本

[英]cordova android updating compileSDK version

I'm new to android application building using cordova-android.我是使用 cordova-android 构建 android 应用程序的新手。

I'm facing issue when updating compileSdkVersion/buildToolsVersion in config.xml of project root directory.在项目根目录的 config.xml 中更新 compileSdkVersion/buildToolsVersion 时,我遇到了问题。

As cordova-android version-9 support api level 29 but as Android SDK API level 30 is available and cordova-android still not provided support yet.作为 cordova-android version-9 支持 api level 29 但作为 Android SDK API level 30 可用并且 cordova-android 仍未提供支持。

I tried updating preferences compileSdkVersion/buildToolsVersion like below in config.xml我尝试在 config.xml 中更新首选项 compileSdkVersion/buildToolsVersion,如下所示

<?xml version='1.0' encoding='utf-8'?>
My first app Test application Your Name Here 我的第一个应用程序测试应用程序你的名字在这里

Can someone help me in updating above two properties, so that apk can be build with latest SDK API level 30.有人可以帮我更新以上两个属性,以便可以使用最新的 SDK API 级别 30 构建 apk。

Based on Cordova requirements and support , current cordova-android@9 supports API level 29 and below .基于Cordova的要求和支持,目前cordova-android@9支持API level 29及以下 We can expect that next version cordova-android@10 will likely to target API level 30 and may need to wait for an official update from Cordova team.我们可以预期下一版本cordova-android@10可能会针对API 级别 30 ,并且可能需要等待Cordova团队的官方更新。 在此处输入图像描述

Until then we can play around with the nightly version of cordova-android@10 from npm在那之前,我们可以使用来自npm夜间版本的cordova-android@10

According to the recent deadlines from Google ,根据谷歌最近的截止日期,

August 2021 - New apps must target at least Android 11 (API level 30) 2021 年 8 月 - 新应用必须至少以 Android 11(API 级别 30)为目标

November 2021 - Existing apps must target at least Android 11 (API level 30) for new app updates 2021 年 11 月 - 现有应用必须至少以 Android 11(API级别 30)为目标才能进行新应用更新

So we can wait till August for an official update:).所以我们可以等到 8 月的官方更新:)。

Workaround:解决方法:
(may or may not work. Use it in a sample application before implementing in the real application) (可能有效也可能无效。在实际应用程序中实施之前在示例应用程序中使用它)

Change android-targetSdkVersion on config.xml在 config.xml 上更改android-targetSdkVersion targetSdkVersion

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

Remove the platform by using使用删除平台

cordova platform remove android

then add the latest cordova android version:然后添加最新的cordova android 版本:

cordova platform add android@latest

Build the project:构建项目:

cordova build android

In your config.xml add / update targetSdk version to 30 like below.在您的 config.xml 中添加/更新 targetSdk 版本为 30,如下所示。

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

Above command will change targetSdk version to 30上面的命令会将 targetSdk 版本更改为 30

Remove platform android and add back with below command删除平台 android 并使用以下命令重新添加

cordova platform add android@10.0.0

Above command will update compileSdk version to 30. If this step isn't done it will give same value as whatever version was available when you added platform.上面的命令会将 compileSdk 版本更新为 30。如果未完成此步骤,它将提供与添加平台时可用版本相同的值。

Also make sure you have latest sdk and build tool is installed for proper command execution.还要确保您拥有最新的 sdk 并安装构建工具以正确执行命令。

Cordova 11.0.0 is out, but to update this highly ranked question, you have to add the following to your config.xml: Cordova 11.0.0 已经出来了,但是要更新这个排名靠前的问题,您必须将以下内容添加到您的配置中。xml:

<preference name="android-minSdkVersion" value="19" />
<preference name="android-targetSdkVersion" value="31" />
<preference name="android-compileSdkVersion" value="31" />

Additionally, apps which target Android 12+ have to add此外,针对 Android 12+ 的应用必须添加

android:exported="true" 

to all Activity and Requirement statements in your manifest -- I had to add this in several places manually to accommodate older plugins.清单中的所有 Activity 和 Requirement 语句——我不得不在几个地方手动添加它以适应旧插件。

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

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