Generate Debug And Production Api Key Google Map Android

Posted : admin On 14.12.2020

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.

  • The Android SDK contains several tools to help you test and debug your Android applications. For more information, see the Debugging and Testing sections in the Dev Guide. Gathering materials and resources. To begin preparing your application for release you need to gather several supporting items.
  • In this article you will create an SHA1 Fingerprint key for Xamarin Android Google Map App Development. Here are the steps, Here are the steps, Create Google Maps API v2 key through the following steps.
Generate

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.

Jun 27, 2018  Walk-through guide on getting a Google Maps API key and building an Android application to show a map. Covers troubleshooting. Avast pro product key generator.

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?

How to&Answers:

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:

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

Answer:

Had the same hassle with the API key. Here’s a full solution, based on the above link and example from Bijarni (which somehow didn’t work for me), I use now this method:

You have to find out your debug signature’s hashValue() once, just output sigs[i].hashCode().

Then, I didn’t want to dynamically add the MapView, but rather use the xml file. You cannot set the api key attribute in the code and use an xml layout, so I use this simple method (though copying the xml layout isn’t so beautiful):

In my MapActivity:

Answer:

Much easier way to determine whether it is a debug build is by checking the debug flag on the application info than the signature hash.

Once debug build is found, either you can use different resource for showing map or create the mapview within the app and add to a layout.

Answer:

I have worked around the horrendous mis-integration of the api keys into the build process and source control by making it a property stored in local.properties. I had to add the following to build.xml:

Now, of course I had to create mapview.xml.tpl in my projects root (it can’t go to res/layout because it will break the build process):

During pre-compilation, the template is copied to the right place and @[email protected] is replaced with the real key. Unfortunately I have not found a way to distinguish between debug and release builds in this phase, so to compile for release, I just add the release apiKey to the ant parameters:

This approach integrates well with SCM (I do not need to check in the keys) and acceptably with the build process.

Answer:

If you’re still interested I just blogged about another way to do this. With a simple change to the Android build script, you can switch the Map API key as well as all other required release changes. What I like about this is that nothing debug-related goes into the release, and you can keep the XML layouts just the way they were before.

Answer:

I think that creating an entry in the Google API’s console which includes both your release key and your debug key (both mapping to the same package) works great and is a much simpler way to not have to worry about whether you are debuging or compiling a release version.
The solution is outlined here

Answer:

All answers here seem outdated, if you are using android studio then gradle is the way to go

Openssl generate key pair for ssh. Use different keys in your build.gradle

And in your AndroidManifest.xml

And if you want to save some passwords for debug and release differently then you should follow this

Api

Answer:

Generate Debug And Production Api Key Google Map Android Hive

I’ve ended up with the special file on SD card – if present, use debug key; missing – use release one. And it works.

EDIT: see new accepted answer, it works better

Answer:

I don’t know if this helps anyone but I have merged some of the other suggestions here to produce the following MapViewActivity.

In this example R.layout.map_dbg is only used if this is a debug build and the file exists (add this file to your .gitignore).

The advantages of this approach are :

  1. you don’t need to write an ant target (good if you use eclipse)
  2. the correct release key is always in map.xml (hopefully a debug key won’t be checked in by mistake)
  3. the release key is always used for a release build
  4. multiple debug keys can be used

The disadvantages of this approach are :

Generate Debug And Production Api Key Google Map Android App

  1. you need to remember to update map_dbg.xml every time map.xml is updated

Generate Debug And Production Api Key Google Map Android Api On My Project 2019

Answer:

I have setup a simple ant target that replaces the apikey with either a debug key or a release key. This is really simple and keeps the code free of unwanted logic.

Generate Debug And Production Api Key Google Map Android Software

Answer:

In Map V2 Its easy to send seperate keys using Android Studio Gradle tool. I have implemented an easy way for that. please check the link here.

Tags: androidandroid, api