我刚刚从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
上解决此问题
最佳答案
<!-- 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/