Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)

(gtxtreme123) #1

For the More Curious: Teams and API Keys


And with that, your little geographic image finder is complete. You learned how to use two Play
Services APIs, you tracked your phone’s location, you registered for one of Google’s many web
services APIs, and you plotted everything on a map. Perhaps a nap is in order now that your app’s map
is in order.


For the More Curious: Teams and API Keys


When you have more than one person working on an app with an API key, debug builds start to be a
pain. Your signing credentials are stored in a keystore file, which is unique to you. On a team, everyone
will have his or her own keystore file and credentials. For new team members to work on the app, you
have to ask them for their SHA1 and then go update your API key’s credentials.


Or, at least, that is one option for how to manage the API key: Manage all of the signing hashes in your
project. If you want a lot of explicit control over who is doing what, that may be the right solution.


But there is another option: Create a debug keystore specifically for the project. Start by creating a
brand new debug keystore with Java’s keytool program.


Listing 34.14  Creating a new keystore (terminal)


$ keytool -genkey -v -keystore debug.keystore -alias androiddebugkey \
--storepass android -keypass android -keyalg RSA -validity 14600


You will be asked a series of questions by keytool. Answer them honestly, as if no one were watching.
(Since this is a debug key, it is OK to leave the default value on everything but the name if you like.)


$ keytool -genkey -v -keystore debug.keystore -alias androiddebugkey \
--storepass android -keypass android -keyalg RSA -validity 14600
What is your first and last name?
[Unknown]: Bill Phillips
...

Free download pdf