After updating gradle to version 3.0.0-beta3 I have this error when I try to display a dialog box to ask for the password of the key.
I tried to add System.setProperty('java.awt.headless', 'false')
but it did not work and I found nothing very new on google ....
Error:(20, 1) Failed to create component for 'dialog' reason: java.awt.HeadlessException
java.awt.HeadlessException (no error message)
import groovy.swing.SwingBuilder
gradle.taskGraph.whenReady { taskGraph ->
def storePassword = ''
def keyPassword = ''
if (System.console() == null) {
new SwingBuilder().edt {
dialog(modal: true, title: 'Enter password', alwaysOnTop: true, resizable: false, locationRelativeTo: null, pack: true, show: true) {
vbox {
label(text: "Please enter store passphrase:")
def input1 = passwordField()
label(text: "Please enter key passphrase:")
def input2 = passwordField()
button(defaultButton: true, text: 'OK', actionPerformed: {
storePassword = input1.password;
keyPassword = input2.password;
dispose();
})
}
}
}
} else {
storePassword = System.console().readPassword("\nPlease enter store passphrase: ")
keyPassword = System.console().readPassword("\nPlease enter key passphrase: ")
}
if (storePassword.size() <= 0 || keyPassword.size() <= 0) {
throw new InvalidUserDataException("You must enter the passwords to proceed.")
}
storePassword = new String(storePassword)
keyPassword = new String(keyPassword)
android.signingConfigs.Keys.storePassword = storePassword
android.signingConfigs.Keys.keyPassword = keyPassword
}
For me it finally worked when I added System.setProperty('java.awt.headless', 'false')
twice:
System.console() == null
checkBut then it happens be ok with only after System.console() == null
check.
Don't forget to ./gradlew --stop
as mentioned before.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With