I develop locally with android-studio and a Galaxy S3 android phone connected via USB.
On my local development environment, when I fire up the run configuration to deploy on the S3, everything works fine - the map shows up just fine.
But when I deploy as signed APK to our server, and install via Internet (I am trying on another android phone to keep things clearly separated), the map tiles don't load, I see the Google sign to the lower left and the GPS location icon on the upper right corner.
I've seen a few related posts:
Android Google Maps application showing grey background instead of the map
which seems first a bit dated, second he uses eclipse (I am using android-studio), third - it didn't work for me.
Android - Google Maps Grey Screen on Signed APK
This guy didn't get any useful answers to his question....
The first step is to get the SHA1 value for the key that you used to sign the release version of your app using the keytool command line tool.
keytool -list -v -keystore ~/Keystore/key1.jks -storepass <your_store_password> -keypass <your_key_password>
Replace ~/Keystore/key1.jks with the path and name of the keystore that you used to sign your release version, and replace the passwords with your own.
When you execute this command at the command line, it will list the Certificate Fingerprints, including the SHA1 value that you need.
The next step is to add the SHA1 and package name to a key in the Google Developers Console.
You can either add it to the same key you used for debug builds, or you can create a new key.
To add your release SHA1 and package name to an existing API key, click the Add package name and fingerprint button, and add your SHA1 value and package name.
Then, you can use this API key with the signed release version of your app.
For more information on how to configure your app if you use a different API key for debug and release, see here.
Step 1: Follow the instructions from here:
http://developer.xamarin.com/guides/android/platform_features/maps_and_location/maps/obtaining_a_google_maps_api_key/
Step 2: Then from your Android Studio, follow the steps described here:
https://www.udacity.com/wiki/ud853/course_resources/creating-a-signed-apk
I faced a similar problem and had it solved by doing the above.
Related
I have a running application in Play Store. I've tested and successfully updated my application three times. Suddenly, I had to change my laptop and reconfigured everything, i.e. Android Studio, JDK, SDK and everything. I knew that the signed key file is important for updating my application. So I backed up my project and the file.
Now I'm going to update my application again and I've noticed that my SHA1 key is changed. I cannot test my G+ login integrated with my app. I think that same problem will arise in GCM also. What should I do?
The Play Store and its APIs were all given the SHA1 of the debug key from your original setup, and that's what it's still expecting.
The easiest thing to do, if possible, is copy the debug key from your old setup to your new setup and rebuild with it. That file is in ~/.android/debug.keystore.
If you don't have your old key available any more, you will have to repeat the process you originally went through to connect your debug builds to whatever Google APIs you use. But this time with the SHA1 of your new key to replace the old key that's no longer being used.
You just need two steps to make your app up and working again:
1) Get your new SHA1 key.
2) Make the changes in the credentiials by going to console.developer.google.com where you have created the API key for signing your application.
Now how you are going to get the updated SHA1 key, for that go to the android studio click on View-> Tool Windows-> Gradle. Open the file with your app name on it and "(root)" written next to it then go to Run Configurations and click on one of the file that you see. That's it you will get your new SHA1 key and MD5 there at the bottom where the configurations are executed.
Update your API key with this SHA1 key and you are good to go!:)
Note: If you can't see the SHA1 key then there is a button next to run button named "Toggle tasks execution/text mode" click on that and you will get the key.
I had the same problem when lost my old pc.
Your app is secure in google play store as the keystores.jks stores the original ShA-1 that identifies your app-identity. If you lost your keystores then you will face others problemas. Here we will resolve the different Sha-1 problem.
The problem you are facing is relative to the debug, as the sha-1 is generated from your pc and its not equal to the one you previously informed.
You need 3 steps:
STEP 1 - Get your new Sha-1.
-Get the path to your new key. Its is in: C:\Users\YOURUSER.android
use this comand in terminal or command prompt -> keytool -list -v -keystore "C:\Users\YOURUSER.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
Copy the sha-1.
STEP 2 - Go to google developers console, find your credentials. Some of them are restricted. Enter in its properties and add the new SHA-1 in the list. Leave the old ones there too. Do it in every restricted credential.
STEP 3 - Go to your firebase console, settings. Then in Apps Android, just add the new SHA-1. This will make work.
I spent a long time tonight trying to figure out how to get my Google Map that worked in the debug version of my Android application to work in the release version. There were a few different problems that came up. Some fragments of Stack Overflow posts helped, but I thought it would be useful to list more detail for the whole process, including the problems I had, which were:
1) How/where do you specify something different for your release version?
2) How do you run the keytool executable needed to get the release version fingerprint?
3) Why was I getting the "keystore file exists but is empty" error when running keytool?
1) As specified in a couple other Stack Overflow posts, you can use the same Google API key for both your debug and release versions, but you have to supply the fingerprints of your debug and release keys in the Google Developers Console.
Log into Google Developers Console https://console.developers.google.com
Choose your appropriate Project
On left side, choose Credentials under "APIs & auth"
Assuming you already have an API Key generated for Android applications, you should already see your application listed as an "allowed application" with its debug fingerprint. Click "Edit allowed Android applications".
You will want to add another line for your application, but with its release fingerprint. To get that...
2) Google mentions in that dialog that you need to run
keytool -list -v -keystore mystore.keystore
But by clicking "Learn more" and going a little further, what you really want to run is
keytool -exportcert -alias MY_RELEASE_KEY_ALIAS -keystore MY_FULL_PATH_TO_RELEASE_KEYSTORE_FILE -list -v
Then you'll be asked for your keystore password. One piece that isn't mentioned in the docs is where the keytool program is. Its in your JDK bin folder. So on Windows, something like C:\Program Files\Java\jdk1.8.0_20\bin
3) After I opened a console window in the Java bin folder and ran the keytool as above, I was getting an error that said "keystore file exists but is empty". Eventually I realized that when specifying the full path to my release keystore file, I had only specified the folder name but forgot to include the actual file name, even though there was only one file in the folder. So MY_FULL_PATH_TO_RELEASE_KEYSTORE_FILE above should include the .keystore file name
After all that, you will be finally be provided with several fingerprints, including the SHA1. You can copy that, and go back and paste it as a new line in the allowed Android Applications, with your package name on the end separated by a semi-colon, just like the debug one.
Follow the instructions given here. After creating your project in Google Developers Console, select APIs, you will be prompted with a section of Popular APIs, select Google Maps Android API. Press enable API.(the image below is showing the steps in the new version of the console)
If you're still using the old console, enable the API, by selecting Services, then switch the button ON:
Note:
You don't need to enable the API for the debug version!
If you're map is still not showing try regenerating the key!
(new version)
(old version)
Enter the new API key then Sync Project with Gradle Files!
do i have to publish the apk everytime in order for the map to show? My map won't display while running via eclipse, i have to export to apk and then install on my deivce to test. Is there a easier way to test a map v2 apk? Thank you!
First thing you have to Use your debug.keystore file from .android folder and then generate SHA1 using that keystore.... in Command Propmt.
And then you have to generate your Google Map v2 API key using this SHA-1 from Google API Console.
And use this key in your application and you don't need to Export your Signed application..
Thanks..!!
You can't display maps in the Emulator since it doesn't have Maps installed in it. You must run all the Maps related applications in your android device.
Also, Just connect your device to the PC/laptop and eclipse will automatically prompt in which device you want to run and then you can select your device.
Its because there is no maps in your emulator. Your map will display only on a pure AVD, i.e. it CPU of emulator must be ARM, and the target should be a Google APIs device. For Maps V2, you need google play services installed in your emulator/device. By default its not available in any emulators.
You can force install google play services into an emulator, follow this for a start.
The better option is to use a device(mobile/tab) via USB with developer options enabled (USB Debugging checked).
Try it...
Use this command to generate SHA1 certificate with your debug.keystore, than generate API key with generated SHA1 certificate
How can I get the MD5 fingerprint from Java's keytool, not only SHA-1?
After generating key from API console use that key to your Manifest file.
There is, but you need to modify your debug key in eclipse (I'm assuming you are using eclipse).
First off, The google mapview stuff only shows when the Api key you are using is derived from the signing key. Here lies the problem - eclipse uses its own default key when you're launching from the IDE.
So you need to use your actual signing key for the debug. If you go to Window -> Preferences -> Android -> Build, you will see that eclipse is using a default debug keystore.
You have there the option to use a custom debug keystore. BUT NO WAY TO SET CUSTOM PASSWORD.
Good thing you can change the password on your original signing key (I prefer to create a copy and tag that as my "debug" key) and still retain all/most of its properties, I honestly don't know which ones, such that you can now use it as a debug keystore and still have it display the google maps layout.
To change keystore password just fire up cmd and do:
keytool -storepasswd -keystore my.keystore
Eclipse uses "android" as the default password for debugging, that's what you enter as new password.
After modifying your key, you can now set it as the custom debug keystore and start going Ctrl+F11 on your android source.
As far as I know, you can even override installation of the normally-signed app on your phone with this technique, so it goes further than just having google maps enabled while debugging.
C:\Program Files\Java\jdk1.7.0_03\bin> keytool.exe -V -list -alias androiddebugk
ey -keystore "C:\Users\Dell.android\debug.keystore" -storepass android -keypass android
type this in CMD.this will give both sha-1 and md5 key..plz change path as per ur machine..!
Make sure that the release API key is in the google_maps_api.xml file under the release/res/values folder, since this is the one that will be used for the signed release apk.
In a project, when I install the app on a handset directly through the Eclipse IDE, I can see the Map functioning perfectly.
But if I send the apk to someone through email and they install it on the device, altough the app works they are not able to see the map but only a blank grid!
We already have the MapKey in the project. For a non-market app, how can I show the map if the app is not installed through the Eclipse IDE on my system?
Each api key is tied to that certificate. When you run a project in eclipse, it uses your debug keystore. When you export it, you most likely are using a different keystore, so your maps api key is no longer valid. Take the keystore you used to signed the exported apk and get a new api key. You'll need to swap the map api key back and forth when you are developing and releasing your app. Hope that helps.
"When you export it, you most likely are using a different keystore, so your maps api key is no longer valid."
Not fully correct, you can Export from Eclipse and then sign map with your key.
So full algorithm is:
1. Export with Eclipse
2. Create key - remember path (say mypath/myawesomeapp.key)
then open Terminal and goto to folder with key and type in terminal
keytool -list -keystore myawesomeappkey.key
And then you get Certificate fingerprint in page https://developers.google.com/android/maps-api-signup
Your Google Maps API key may not match the certificate you used to sign the application, since if you use different keys for signing development builds and release builds, you will need to obtain a separate Maps API key for each certificate.
Please, check this page to find out how to generate a proper API key for Google Maps API: https://developers.google.com/android/maps-api-signup
I'm developing an app that uses Google Maps. I got the debug keystore and got the API key to work while I am debugging my program in Eclipse, but I am thoroughly confused in how to change this so that it works on an Android device when I export the .apk. I have searched around Google, but am mainly finding things that use the debug.keystore and I don't think this is what I want to use when I deploy this on an Android device, because I sent my .apk to a friend and he said he is getting gray boxes on the Map View.
Can anyone fill me in, step-by-step, on how to correctly make a new keystore for my app and how to sign my app so that it will work outside of debugging on Eclipse? A video tutorial would be preferable, but if not, simple 1-2-3 step type instructions would work. Thanks!
Eclipse (through ADT) has a nice wizard that lets you create a real keystore and build a signed apk. Right click your project, then Android Tools -> Export signed Application package
For the google maps key just follow these instructions
head to the command prompt, (I use windows so I'm going to go that route but same general idea for the other OS's)
The keytool program you'll need is part of the JDK so you do have it if your able to compile the apps at all. but it may not be on the app path so you can't just type it into the command line to be used.
for me it was in:C:\Program Files\Java\jdk1.7.0_21\bin so to get it on the app path I typed this in set PATH=%PATH%;C:\Program Files\Java\jdk1.7.0_21\bin
next you need to change to the directory your keystore files are in for me that is: C:\android\keys so I used the command cd C:\android\keys to change to the proper directory
then you need to run the keytool with the proper settings so it knows your after the key and not trying to do something else. the command I used was: keytool -list -v -keystore Testkeys and Testkeys is the name of my keystore use the name of your keystore there instead.
Last by not least it will spit out a whole bunch of different information but the one your looking for will look something like this
SHA1: A1:DF:83:DD:04:B2:26:10:B2:EB:26:00:90:75:D0:10:66:5E:A9:8A
you want all the numbers and : that are after the "SHA1: " that is your app key for the published version of your app, the one you need to register with the google maps api service, and then they will give you a new map api key that you need to put in your project and then republish it, and then the maps will work.