AS从控制台或者环境变量中获取签名文件密码的方法
2016-09-19 18:07
357 查看
原文地址: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 } }
| |||||||||||||||||||||||||||||
|
相关文章推荐
- Android获取屏幕高度、状态栏高度、标题栏高度
- Jmeter之 c31a 二:逻辑控制器学习(一)
- 活动里面添加一个碎片
- 论我国24字核心价值观及其世界意义
- RelativeLayout布局用到的主要属性
- java基础:抽象类(09.27)
- Android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed
- 9.19练习
- XHR
- hadoop基础----hadoop实战(五)-----myeclipse开发MapReduce---WordCount例子---解析MapReduce的写法
- Maven搭建SpringMVC+Mybatis项目详解【转】
- hadoop基础----hadoop实战(五)-----myeclipse开发MapReduce---WordCount例子---解析MapReduce的写法
- 网站每日PV/IP统计/总带宽/URL统计脚本分享(依据网站访问日志)
- 邮箱正则校验
- iOS 无效的版本,提交成功,不出现版本号
- xfs_repair 时间花费与数据量关系
- ==与.equals方法的比较区别
- javascript高级程序设计——笔记
- table在网页中的居中显示
- 简述配置文件ini及其操作函数GetPrivateProfileString等