How to configure Android sdk v2 card to use different keys for production and development?

I want to automatically install various Android api V2 keys for development and production.

+14
android google-maps ant google-maps-android-api-2 android-mapview
Dec 14
source share
3 answers

Log in to the Google API console In the "Easy API Access" section, click "Change allowed Android apps ..." on the right side. Enter one SHA-1 fingerprint per line, as indicated in the instructions:

"One fingerprint of the SHA1 certificate and the package name (separated by a semicolon) per line Example: 45: B5: E4: 6F: 36: AD: 0A: 98: 94: B4: 02: 66: 2B: 12: 17: F2: 56: 26: A0: E0; com.example 45: B6: E4: 6F: 36: AD: 1A: 98: 94: B4: 02: 66: 2B: 12: 17: F1: 56: 26: A0: E0 ; com.example "

Now just use the same "Simple API key" and it will work for your debugging and publishing the certificate without having to change anything.

+21
Dec 14 '12 at 15:30
source share

Maybe I'm wrong, but I think you can use the same V2 API key for development and build. In your Google APIs console, after creating a simple Android key, you just need to enter the SHA-1 fingerprints of your product signature key and all the keys for signing Android debugging that you may have. Then, in your manifest, just use this simple Android key, and the application should work for both debug builds and builds.

+7
Dec 14 '12 at 18:13
source share

One of the easiest solutions. You can achieve this with two simple steps.

Add a custom value to the build.gradle manifest build.gradle . See below

 buildTypes { debug { manifestPlaceholders = [ mapApiKeyValue:"GHjaSyAjlyp3O831lgaonHMXsd-_DpQ3002x3S4"] } release { manifestPlaceholders = [ mapApiKeyValue:"AIzaSyAuMGDLr2HeuRed4JA0CrdYYdZRjeC3EA"] } } 

Edit the manifest file as shown below. part of my manifest file

  <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="${mapApiKeyValue}" /> 

This solution works for the latest Android 5.0 and Android 6.0 (API 20, 21,22,23)

+3
Nov 08 '16 at 10:17
source share



All Articles