首先,我是新手,所以这可能是一个愚蠢的问题,但我无法找到解决方案.我试图在终端中构建一个签名的Android .apk文件,我想使用命令行来传递一些参数:
gradle assembleRelease -PkeyPw='secret123' -PstorePw='secret123' -PkeyAlias='My-Testkey' -PkeyLocation='/home/someUser/test-key.keystore'
Run Code Online (Sandbox Code Playgroud)
现在我想在build.gradle文件中使用这些变量:
signingConfigs {
release {
storeFile $keyLocation
storePassword $storePw
keyAlias $keyAlias
keyPassword $keyPw
}
}
Run Code Online (Sandbox Code Playgroud)
但它们是空的(可能是因为它根本没有任何意义,但我没有找到如何做到这一点).
谢谢你的帮助!
编辑
我使用命令从java运行gradle构建
new ProcessBuilder().inheritIO.command(cmd).start
Run Code Online (Sandbox Code Playgroud)
并得到以下错误:
FAILURE: Build failed with an exception.
* Where:
Build file 'somePlace/app/build.gradle' line: 16
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find property 'keyLocation' on project ':app'.
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to …Run Code Online (Sandbox Code Playgroud)