Gradle-based builds
1) Create a secure.properties
file to contain your passwords:
key.store.password=<your keystore password>
key.alias.password=<your alias password>
You probably don't want it under version control, which is why we're putting the passwords in a separate *.properties
file. If you don't mind having your passwords under version control, you can enter your passwords directly into build.gradle
, but that's not recommended, so I'm not directly showing that.
2) Set up your build.gradle
as follows:
Properties secureProperties = new Properties()
secureProperties.load(new FileInputStream("secure.properties"))
android {
signingConfigs {
release {
storeFile file("<path to your keystore>")
storePassword secureProperties['key.store.password']
keyAlias "<alias name>"
keyPassword secureProperties['key.alias.password']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
And that's it. ./gradlew assembleRelease
now builds and signs my APK without prompting for my password.
Ant-based builds
1) Create a secure.properties
file to contain your passwords:
key.store.password=<your keystore password>
key.alias.password=<your alias password>
You probably don't want it under version control, which is why we're not putting the passwords in one of the existing *.properties
files. If you don't mind having your passwords under version control, put these two lines in ant.properties
and you're done.
2) Create a custom_rules.xml
file to tell the build system about your secure.properties
file.
<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules" default="help">
<property file="secure.properties" />
</project>
I'm not familiar with this build system, so I'm not sure about the project
element's name
or default
properties, but I believe what I chose should work for everybody.
2b) Any recent version of the Android SDK tools should be good to go, but if for some reason your build.xml
file doesn't contain the following, you should add it:
<import file="custom_rules.xml" optional="true" />
And that should be it. ant release
now builds and signs my APK without prompting for my password.