gradle - gradlew assembleDebug requires my release key password -
i added signing settings the guide says. when run ./gradlew assembledebug
, requires keystore , key passwords, , there 2 apk files @ end:
- ./main/build/outputs/apk/main-debug.apk
- ./main/build/outputs/apk/main-debug-unaligned.apk
so gradle builds debug version of module requires release key.
the build.gradle file of built module below.
apply plugin: 'android' android { compilesdkversion 19 buildtoolsversion '19.1.0' signingconfigs { release { storefile file("my-release-key.keystore") storepassword system.console().readline("\nkeystore password: ") keypassword system.console().readline("key password: ") keyalias "my_key" } } defaultconfig { minsdkversion 9 targetsdkversion 19 versioncode 1 versionname "1.0" } buildtypes { release { runproguard true proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.txt' signingconfig signingconfigs.release } } } dependencies { compile 'com.android.support:support-v4:19.0.1' compile 'com.android.support:appcompat-v7:19.0.1' compile project(':log-wrapper') compile 'com.google.android.gms:play-services:+' }
update #1.
the solution on https://stackoverflow.com/a/24281294/1065835 works, , accepted answer. prefer using approach described here. release keys stored locally , safely, , there no need type passwords every time when compiling release version.
seems merge suggestions picked here , there.. ..and got working.
the problem seems fact writing anywhere in build.gradle like:
storepassword system.console().readline("\nkeystore password: ")
it executed anytime.
the solution put was, creating signingcongif block before buildtypes block:
signingconfigs { release { storefile file("c://my.keystore") storepassword "" // required otherwise cannot overwritten keyalias "myalias" keypassword "" // required otherwise cannot overwritten } } buildtypes { [...]
and tweaking gradle configuration this:
gradle.taskgraph.whenready { taskgraph -> if(taskgraph.hastask(assemblerelease) || taskgraph.hastask(installrelease)) { // execute when trying assemble release build def passkeystore = system.console().readline("\nkeystore password: ") def passkey = system.console().readline("\nkey password: ") android.signingconfigs.release.storepassword = passkeystore android.signingconfigs.release.keypassword = passkey }
}
note that:
1. block outside , before "android {}" one.
2. tested in command line execution only. seems fixes needed no console available.
Comments
Post a Comment