gpt4 book ai didi

android - Cordova:java.lang.IllegalStateException:未指定 compileSdkVersion。

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:41:20 25 4
gpt4 key购买 nike

我将我的 cordova 环境更新到 Cordova Android 7 并在 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

有人知道解决方案或解决方法吗?

最佳答案

通过运行以下命令

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 多次。

关于android - Cordova:java.lang.IllegalStateException:未指定 compileSdkVersion。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49150216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com