每次使用Android Studio或CLI尝试对apk文件签名时,都会出现以下错误:
BUILD FAILED in 4s
cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* Where:
Script 'C:\coderepo\puppydogmobile\puppydogmobile\platforms\android\CordovaLib\cordova.gradle' line: 148
* What went wrong:
Failed to create component for 'dialog' reason: java.awt.HeadlessException
> java.awt.HeadlessException (no error message)
我已经看到很多关于此错误的评论,但没有修复仅解决许多情况下无法解决的问题。谁能告诉我这个问题是否有更新。 我尝试了以下解决方案:设置
System.setProperty('java.awt.headless', 'false') from
https://stackoverflow.com/questions/45909265/failed-to-create-component-for-dialog-reason-java-awt-headlessexception
它没有用'
我得到的最后一条建议是像这样在Platforms \ android \ CordovaLib \ cordova.gradle文件中对密钥库pswd进行硬编码:
def doPromptForPassword(msg) {
if (System.console() == null) {
def ret = 'password'
new SwingBuilder().edt {
dialog(modal: true, title: 'Enter password', alwaysOnTop: true, resizable: false, locationRelativeTo: null, pack: true, show: true) {
vbox {
label(text: msg)
def input = passwordField()
button(defaultButton: true, text: 'OK', actionPerformed: {
ret = input.password;
dispose();
})
}
}
}
无论如何都是很低的黑客和安全风险,并且没有用。我真的需要知道解决这个问题的最新方法!
这是我的环境 离子性:
ionic(Ionic CLI):4.2.1(C:\ Users \ maenn \ AppData \ Roaming \ npm \ node_modules \ ionic) 离子框架:离子角3.9.2 @ ionic / app-scripts:3.1.8
科尔多瓦:
cordova(Cordova CLI):8.1.2(cordova-lib@8.1.1) Cordova平台:Android 6.4.0 Cordova插件:cordova-plugin-ionic-keyboard 2.1.3,cordova-plugin-ionic-webview 1.2.1(和其他17个插件)
系统:
Android SDK工具:26.1.1(C:\ Users \ maenn \ AppData \ Local \ Android \ Sdk) NodeJS:v8.11.4(C:\ Program Files \ nodejs \ node.exe) npm:5.6.0 作业系统:Windows 10
我的目标也是这样设置的:
defaultConfig {
versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
applicationId privateHelpers.extractStringFromManifest("package")
if (cdvMinSdkVersion != null) {
minSdkVersion cdvMinSdkVersion
}
minSdkVersion 16
targetSdkVersion 26
}
我还使用Android Studio 3.3.2构建APK和捆绑软件。