AS从控制台或者环境变量中获取签名文件密码的方法
来源:互联网 发布:天刀涂山红红捏脸数据 编辑:程序博客网 时间:2024/05/18 03:31
原文地址:http://stackoverflow.com/questions/18328730/how-to-create-a-release-signed-apk-file-using-gradle
有空翻译,Mark
Note that @sdqali's script will (at least when using Gradle 1.6) ask for the password anytime you invoke any gradle task. Since you only need it when doing gradle assembleRelease
(or similar), you could use the following trick:
android { ... signingConfigs { release { // We can leave these in environment variables storeFile file(System.getenv("KEYSTORE")) keyAlias System.getenv("KEY_ALIAS") // These two lines make gradle believe that the signingConfigs // section is complete. Without them, tasks like installRelease // will not be available! storePassword "notYourRealPassword" keyPassword "notYourRealPassword" } } ...}task askForPasswords << { // Must create String because System.readPassword() returns char[] // (and assigning that below fails silently) def storePw = new String(System.console().readPassword("Keystore password: ")) def keyPw = new String(System.console().readPassword("Key password: ")) android.signingConfigs.release.storePassword = storePw android.signingConfigs.release.keyPassword = keyPw}tasks.whenTaskAdded { theTask -> if (theTask.name.equals("packageRelease")) { theTask.dependsOn "askForPasswords" }}
Note that I also had to add the following (under android) to make it work:
buildTypes { release { signingConfig signingConfigs.release }}
0 0
- AS从控制台或者环境变量中获取签名文件密码的方法
- Java从控制台获取数据的方法
- java程序中获取项目或者目录或者文件路径的方法
- Java从控制台获取输入的两种方法
- JS从JSP文件中获取数据的方法
- 从文件路径中获取文件名的方法
- 从.properties文件中获取配置数据的方法小结
- 从xml文件中获取Bean的方法
- jni中调用java方法获取当前apk的签名文件md5值
- java中获取从控制台输入的内容
- Windows 控制台命令 编写简单的bat文件(从控制台获取输入的变量)
- 控制台获取、更改环境变量
- NDK开发中获取java方法的签名方法
- Java中从控制台读取输入的方法的总结
- 关于android studio 下获取签名文件SHA1的方法
- java中从控制台读取输入的三种方法
- Qt中调用控制台并从控制台获取输入
- git 从别的分支checkout文件或者路径的方法
- XHR
- 解决UIColor设置值溢出的警告(UIColorBreakForOutOfRangeColorComponents)
- 9.19练习
- java基础:抽象类(09.27)
- RelativeLayout布局用到的主要属性
- AS从控制台或者环境变量中获取签名文件密码的方法
- Migrating From Eclipse to IntelliJ IDEA
- Jmeter之二:逻辑控制器学习(一)
- iOS- Https适配摸索
- 【智能路由器】ndpi深度报文分析之协议分析器
- AttributeError: ‘module’ object has no attribute’xxx’
- URL截取问题
- centos 安装java
- 大型网站架构演变之路和知识体系[转载]
installRelease
disappeared from the list of tasks... Why? – Kaarel Oct 17 '13 at 18:32KEYSTORE
needs to be defined even for debug builds and for "gradle sync" inside Android Studio, otherwise it'll give an error about path being null. – Jerry101 Mar 31 '14 at 8:07System.console()
is not available, try something like:def storePw = new Scanner(Runtime.getRuntime().exec("/usr/libexec/openssh/ssh-askpass Keystore Password").getInputStream()).useDelimiter("\\n").next()
– codebeard Apr 23 at 5:14