Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting debug keystore or release keystore programmatically

I was wondering if there was a way to detect if the program is running on the default (debug) keystore (when running from eclipse) or on a signed keystore (when released to Android market)

I use Google Maps in my application and I would like programmatically change the Maps API key appropriately for testing and release since the one API key only works for either testing or release.

There must be a way to do this since Google Maps can detect what keystore was used to compile the application (to enable or disable the maps).

like image 775
Kurru Avatar asked Oct 11 '22 18:10

Kurru


2 Answers

http://daniel-codes.blogspot.com/2011/04/detecting-keystore-signature-in-code.html

This seems like an appropriate method to identify release keys

Also

http://whereblogger.klaki.net/2009/10/choosing-android-maps-api-key-at-run.html

Also

Android: automatically choose debug/release Maps api key?

like image 75
Kurru Avatar answered Oct 14 '22 01:10

Kurru


I don't know how Google Maps does its thing, but here's a possible alternative: You can use the package manager to pull the certificate used to sign the APK and compare it to your known release keystore. I suggest comparing it to this rather than your debug keystore because the debug store expires yearly; your release store will not expire for quite a long time (if you followed Google's guidelines).

like image 26
mah Avatar answered Oct 14 '22 01:10

mah