I am trying to integrate an Android app with Travis CI. My application needs an api key that should not be sent to the repo. So, I put the api key in the global gradle properties file ~/.gradle/gradle.properties:
MY_SECRET_API_KEY="aaaabbbcccdddeeefff"
Then I read this value in the file app/build.gradle(which is in the open repository) and set it as the buildconfig field:
apply plugin: 'com.android.application'
android {
buildTypes.each {
it.buildConfigField "String", "API_KEY", MY_SECRET_API_KEY
}
}
and use this api key in the application code by contacting BuildConfig.API_KEY.
I get the following error message from Travic CI: Could not find property "MY_SECRET_API_KEY" on com.android.build.gradle.AppExtension_Decorated.