react-native-google-places
react-native-google-places copied to clipboard
Having two API Key for different configurations
Hello,
Is there any possibilities to put the API Key outside the file "Gradle.properties" ?
I have a development config (productFlavors) and a production one and I would like to use two different API Key. However, I can not switch it each time I make an apk.
Ideally I would like to do something like this (either by manifest placeholder or by build config value):
productFlavors {
beta {
dimension 'env'
applicationId "com.my.fake.package"
signingConfig signingConfigs.release
manifestPlaceholders=[google_api:"my-dev-api-key"]
}
prod {
dimension 'env'
applicationId "com.my.fake.package"
signingConfig signingConfigs.release
manifestPlaceholders=[google_api:"my-prod-api-key"]
}
}
Can you please help me in how to proceed ?
Thanks
Not sure about productFlavors
but with buildTypes
I use:
buildTypes {
debug {
resValue "string", "places_api_key", "AIza..."
}
release {
resValue "string", "places_api_key", "AIza..."
}
What I do is export it from android/gradlew
which sources it from my .env
file. I use react-native-config
. See https://github.com/OurVoiceUSA/HelloVoter/commit/75ae7eded0b0cb70656ef837e04c58b85b89c299