我将我的cordova环境更新到Cordova Android7,在cordova build android --device --verbose时得到以下错误。
Command finished with error code 0: /usr/libexec/java_home
ANDROID_HOME=/Users/kano/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home studio Subproject Path: CordovaLib Subproject Path: app Running command: /Users/kano/git_repositories/ncdc/KuiManagementSystem/app/platforms/android/gradlew cdvBuildDebug -b /Users/kano/git_repositories/ncdc/KuiManagementSystem/app/platforms/android/build.gradle
-Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pandroid.useDeprecatedNdk=true
publishNonDefault is deprecated and has no effect anymore.
All variants are now published. Failed to notify ProjectEvaluationListener.afterEvaluate(),
but primary configuration failure takes precedence.
java.lang.IllegalStateException: compileSdkVersion is not specified.
at com.google.common.base.Preconditions.checkState(Preconditions.java:456)
at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:590)
at com.android.build.gradle.BasePlugin.lambda$null$3(BasePlugin.java:555)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81)
at com.android.build.gradle.BasePlugin.lambda$createTasks$4(BasePlugin.java:551)
at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:91)我添加了以下参数,但结果相同。
$ cordova build android --device --verbose -- --gradleArg=-PcdvCompileSdkVersion=26有没有人知道解决方案或解决办法?
发布于 2019-07-23 22:15:28
通过运行以下命令
ionic cordova build android --prod --no-build我突然遇到了同样的问题:
java.lang.IllegalStateException: compileSdkVersion is not specified.也许你的问题是不同的,但你应该能够像我现在描述的那样追踪你的问题。
如果你进一步阅读,会有更多的信息:
FAILURE: Build failed with an exception.
* Where: Script '/***/platforms/android/CordovaLib/cordova.gradle' line: 132其函数如下:
def doExtractIntFromManifest(name) {
def manifestFile = file(android.sourceSets.main.manifest.srcFile)
def pattern = Pattern.compile(name + "=\"(\\d+)\"")
def matcher = pattern.matcher(manifestFile.getText())
matcher.find()
println('Crashing name: ' + name) // <-- I added this line
return new BigInteger(matcher.group(1))
}我添加了一个println,想看看哪一个崩溃了。输出结果是(运行上面的命令来构建android):
Crashing name: versionCode好的,我在我的config.xml中有如下设置:android-versionCode="0.0.1"
那到底是怎么回事?RegExp不再与该模式匹配。
var a = 'android-versionCode="1"';
var a1 = 'android-versionCode="1.0.0"';
var b = new RegExp('versionCode' + "=\"(\\d+)\"");
console.log('With Version as 1:', b.exec(a));
console.log('With Version as 1.0.0:', b.exec(a1));
实际上,cordova手册页面指出,它应该是以下方式:
https://cordova.apache.org/docs/de/latest/config_ref/
<widget id="io.cordova.hellocordova"
version="0.0.1"
android-versionCode="7"
ios-CFBundleVersion="3.3.3">versionCode = PATCH + MINOR * 100 + MAJOR * 10000
CFBundleVersion = "MAJOR.MINOR.PATCH"希望这会对一些人有所帮助,因为现在这个问题已经在3000+上被浏览了很多次。
发布于 2018-07-27 17:58:36
我在使用的时候遇到了和你一样的错误
cordova run android我在项目中降级了我的android平台,解决了这个问题
cordova platform remove android然后
cordova platform add android@6对我来说,6运行得很好
发布于 2021-09-03 10:01:53
在我的例子中,错误来自我自己的插件,我通过在我的plugin.xml文件中添加以下行来修复它:
<platform name="android">
<preference name="android-compileSdkVersion" value="30" />
...https://stackoverflow.com/questions/49150216
复制相似问题