8
votes

I just generated the Google Maps API key to use in my android app. I had to provide the SHA-1 fingerprint and the package name for the application. It looked something like this:

BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75;com.example.android.mapexample

As you can see I had to provide the package name for the app. So, does this mean that I need to get a different API key for different applications?

PS: Curiously, somehow, Google generated two API keys for the SHA-1 and package name combination I entered. Is this normal? And so, which one should I use?

4

4 Answers

9
votes

You can use the same keystore and the API key for different applications.

  1. Use the same key to sign your apps.
  2. Add a line for each application in the Console page.

So, something like this:

BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75;com.example.android.mapexample
BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75;com.example.android.anotherapp
BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75;com.example.temp.lastapp

And now, you can use the same API key with all these apps.

1
votes

Old question, but the accepted answer is against best practice. You can use the same API key, but it is best not to. From the Best Practices Docs:

Use independent API keys for different apps. This limits the scope of each key. If an API key is compromised, you can delete and revoke the impacted key without needing to update your other API keys.

1
votes

Add your projects with SHA1 and Packages in Google Cloud console.

You can absolutely use the same key for different Android Apps. Just add all your applications package names and SHA keys at the Google Cloud Platform console. And it will work 100%.

enter image description here

How to get SHA1?

I have noticed that the SHA1 key is the same when you generate with Android Studio. You can generate SHA1 key by Gradle signingReport Task

enter image description here

0
votes

You can use the same SHA-1 print for different pacakages, but you'll have to make different API keys for different apps. And yes, Google will generate a new key everytime you make a request.