Android Travis CI with Autodeploy (API 26+)
Gerard Rovira
502

Hi Gerard,

It’s working nicely. Did the following

1. Added this small piece of code to the app’s gradle file:

// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("keystore.properties")

def keystoreProperties = new Properties()

// Load your keystore.properties file into the keystoreProperties object.
def canSign = false
try {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
canSign = true
logger.info("Found keystore properties file")
} catch (Exception ex) {
logger.warn("Unable to load keystore properties files. Pay attention you won't be able to compile a release version. $ex.message")
}

2. Under the android section added:

if (canSign) {
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}

}
}

3. Under build types added:

release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (canSign) {
signingConfig signingConfigs.release
}
}

Under .travis.yml I created keystore.properties file using printf command, e.g.

— printf storePassword=$storePassword\\nkeyPassword=$keyPassword\\nkeyAlias=test\\nstoreFile=${TRAVIS_BUILD_DIR}/android-app.keystore > ${TRAVIS_BUILD_DIR}/keystore.properties

and that’s it. the rest is the same