Reputation: 956
Just finished coding an Android app and am preparing to release it to the Play Store. During development, I obtained a Google Maps API Key using my debug.keystore, and placed this key in my Manifest, like so:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY_API_KEY" />
However, I've now signed my app with my release certificate, and thus got a new API key from Google Maps. For testing purposes, is there a way to keep both the old (debug) and new (release) API key in my Manifest, with a switch that loads the proper one at run time? Ex:
if (debug) {
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="DEBUG_API_KEY" />
}
else if (release) {
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="RELEASE_API_KEY" />
}
Cheers!
Upvotes: 4
Views: 1593
Reputation: 650
<!-- RELEASE key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/release_map_key" />
<!-- DEBUG key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/debug_map_key" />
You add multiple api key in manifest like above. But you can use same api key for both debug and release.
Upvotes: 0
Reputation: 22232
You may use the same key for multiple signing keys or even multiple applications.
On the API Console edit allowed apps and add SHA;package pairs, one pair per line.
Upvotes: 8