android - 升级到Cordova Android 8.0后,Gradle无法同步

标签 android cordova gradle android-min-sdk

我刚刚从Cordova 7.1.4升级到Cordova 8.0.0。在WebStorm上构建成功,但是交付的apk无法安装,当我在Android Studio中打开它时,gradle无法与以下错误同步:

The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.

    Open Manifest File

Move minSdkVersion to build file and sync project

”。

我可以在Android Studio上修复这些错误,但我需要WebStorm才能提供有效的apk。
我在config.xml中添加了<preference name=”android-minSdkVersion” value=”19" />,但未从那里读取。
关于Cordova 8.0.0的更改,提到了“使用自定义Gradle属性从minSdkVersion读取config.xml值”,但我不明白这是什么意思。。

知道此脚本的外观如何吗?
任何想法都欢迎。

PS:我知道after_prepare已解决此问题,它从config.xml文件读取Cordova 9.0.0,但我需要在minSdkVersion上解决此问题

最佳答案

查看this plugin

   <!-- These preferences are actually available in Cordova by default although not currently documented -->
<custom-preference name="android-minSdkVersion" value="10" />
<custom-preference name="android-maxSdkVersion" value="22" />
<custom-preference name="android-targetSdkVersion" value="21" />

<!-- Or you can use a custom-config-file element for them -->
<custom-config-file target="AndroidManifest.xml" parent="/*">
    <uses-sdk android:maxSdkVersion="22" android:minSdkVersion="10" android:targetSdkVersion="21" />
</custom-config-file>

如果失败,那么您可以选择

build-extras.gradle with the following content:

allprojects { project.ext { defaultMinSdkVersion=21 } }

copy this file in the platforms/android folder with a before_build hook and it does the job.



或这个

changing lines in file: platforms/android/gradle.properties

org.gradle.daemon=true org.gradle.jvmargs=-Xmx2048m android.useDeprecatedNdk=true cdvMinSdkVersion=21

to

org.gradle.daemon=true org.gradle.jvmargs=-Xmx2048m android.useDeprecatedNdk=true cdvMinSdkVersion=19



reference

关于android - 升级到Cordova Android 8.0后,Gradle无法同步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57219569/

相关文章:

javascript - Windows Phone 8 IE 1px 水平滚动条

android - 任务 ':app:minifyReleaseWithR8' .java.lang.NullPointerException 执行失败(无错误消息)

gradle - 在Gradle中复制整个目录

gradle - 如何从另一个gradle文件访问值?

java - 计算 JSONArray 中的字符串和 JSONObject 的数量

angularjs - 使用 Angular 的 Cordova APP 中 WWAHost 中未处理的异常

带线程的android异步任务

node.js - Cordova 安装错误 : path issue (? ) - 错误代码 ENOENT

android:Theme.Material.Light 需要 API 级别 21(当前最低为 8)

安卓 ImageView ScaleType *FIT_TOP*