OBSOLETED: this old question refers to obsoleted Google Maps v1 API. When using v2 API, you can use multiple certificate fingerprints in one Google API Console entry. API Key is no longer stored in Manifest nor code.
Is it possible to automatically detect, which certificate was used for signing APK? I'd like to have both debug and release Maps certificates in application and pass valid one to MapView constructor.
With such setup I will not make mistake while releasing application - I'm using debug certificate on emulator and my device, then sign with release one before sending app to Market.
I was thinking about detecting my particular device or whether debugger is connected but it is not perfect. Maybe some file marking need for debug certificate? Is there any better way?
API keys are required for apps and projects that use the Google Maps Platform APIs and SDKs.
Yes you need to setup a billing account, there is no way around it these days.
When you use API keys in your applications, take care to keep them secure. Publicly exposing your credentials can result in your account being compromised, which could lead to unexpected charges on your account.
API keys are not strictly secret as they are often embedded into client side code or mobile applications that consume Google Cloud APIs. Still,they should be secured and should never be treated as public information.
There is a new way to determine is it a debug build or release one in SDK Tools, Revision 17. An excerpt from new features overview:
Builds now generate a class called BuildConfig containing a DEBUG constant that is automatically set according to your build type. You can check the (BuildConfig.DEBUG) constant in your code to run debug-only functions.
So now you can simply write something like this:
if (BuildConfig.DEBUG) { //Your debug code goes here } else { //Your release code goes here }
UPDATE: I've encountered bug in ADT: sometimes BuildConfig.DEBUG
is true
after exporting application package. Description is here: http://code.google.com/p/android/issues/detail?id=27940
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With