Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
225 views
in Technique[技术] by (71.8m points)

android - Can I have a single Google Maps API key for all my apps without registering their package names?

I have written an android library project that includes custom MapFragments, based on Google Maps for Android v2 API. In the Google APIs console, I have registered the library's package name with my debug/signed certificates.

I need to create various apps that use this library as common code base and I was wondering if there is a way to still use the MapFragments of the library, without having to add each app's package name in the Google APIs console. I need this because I want to automate app creation (with Jenkins) and I don't want any manual steps, like logging in to the APIs console and registering the package name.

So far, I haven't managed to find a way to do this. Wildcards don't work (e.g. having com.mycompany.* as package name in the console), and if I don't explicitly register each app's package name, the map doesn't load.

Is it possible to somehow make the MapFragments look up the library's single api key/package, instead of the app's?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here's how to accomplish what you're trying to do when creating a new API key:

  • Click create new Android key button
  • Don't enter anything into the package names list
  • Click create

Then you should see AndroidApps: Any app allowed, and be able to use that maps API key in all of your apps without any configuration on the APIs console.

Since you have probably already have entered the certificate fingerprints for each of your applications, just click Edit allowed Android apps, delete them all from the list, click update, and it should say any app is allowed to use that API key.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...