Gradlew on Windows - System.console() is null

2019-08-10 04:15发布

I want to use System.console() in my build.gradle to let the user enters the password for the keystore.

But then i execute

gradlew assembleRelease --no-daemon

i always get

Cannot invoke method readPassword() on null object

How can i request user input for gradlew on windows?

I searched a lot on google and stack overflow but nothing works.

2条回答
Rolldiameter
2楼-- · 2019-08-10 04:22

There are some known issues with using System.console() in Gradle. If --no-daemon doesn't help (it helps to some extent on my Mac), there is likely nothing you can do to make it work (except to submit a pull request to the Gradle project that fixes the problem). One way to work around the console input issues is to pop up a Swing dialog instead.

查看更多
狗以群分
3楼-- · 2019-08-10 04:34

Then don't use gradlew . Use gradle instead. Gradlew runs in the back ground, which is not interactable and therefore how would you enter input that wants to be read?

查看更多
登录 后发表回答