Google map gets displayed on device when I plug it to my machine and run app from eclipse. But when I run the same code from another machine's eclipse map is not displayed.
It shows "Failed to load map. Could not contact google services. This is probably due to wifi connection or the request is not authorized."
I have all the permission and other manifest tags added correctly with correct API key. This is obvious as it runs from my machine.
Has anyone encountered similar problem?
As the API key is coupled with your debug keystore, the best way would be to copy this keystore to other machines, which are also used for development. debug.keystore is in .android folder in your user folder.
I know the answer for your problem! You need a new API Key for the new machine you are trying to launch the app from. You'll need the SHA1 fingerprint of the new machine in order to create the new API Key in the API Console.
With the new Android Development Tools you can do this very easily. You no longer need to find the debug.keystore and the java bin files to run the previous command line in the command console that generates the SHA1.
To generate the SHA1: Open ADT. Go to Main Menu Window => Preferences => Android => Build. There you have the SHA1 and MD5 options. You know what to do now: join the SHA1 with the package of your project: e.g. SHA1;myandroid.project.
You have the new Key for the new machine. Update the manifest.xml and run the project again. It should work now.
I have just noticed another issue: Be careful when you create your apk file, if you sign it with a keystore you have created, your application map don´t work. I have read that you have to sign it with the same file you have used for creating the API key(debug.keystore). Keep this in mind !
You may be run your code in newer system. For that you need to get new API key using the new SHA1 from the console.
Orelse,
Follow the process,
Go to the home of your older system
Find the location ---- /.android/debug.keystore
Copy the debug.keystore
Replace the debug.keystore in your newer system
Your map will be working fine.
Advance wishes :)
You can't just move your code to another machine and expect it to work.
As been mentioned already you Google Map uses an API key that was produces using the SHA1 fingerprint from the debug.keystore folder in your user folder.
In order this to work you have 2 choices:
1. Copy the the debug.keystore to the other machine you want to develop this project on.
2. Register the SHA1 fingerprint from the new machine into the console as well.
Have you added the keyhash from the other machine to your Google API Console account?
Related
Using app bundles and play app signing is currently the way recommended by google to deploy new apps on google Play. And starting from August 2021 new apps will be strong-armed into using these formats.
How do I set this up in Unity, and how do I configure the app in Google Play?
I haven't gotten 2019.4 app bundle builds to sucessfully upload to play console, so it's probably a good idea to upgrade to the 2020.3 LTS before you start (as that's what finally worked for me.
Configuring Google Play App signing
First create a new app in Play Console, give it a name, accept terms etc.
Then, click Internal testing on the menu on the left side, and create a new internal release.
In the first question, click Change App Signing key, Use a different key and then select the third option, where you can upload your existing key (and an optional step with to add an upload key) to Google Play.
Now, don't just follow the instructions listed on Google Play, as you will end up with an upload key store that Unity doesn't know how to deal with.
Instead, using Unity, we will create two key stores and two keys. The first one is the app signing key, which you will only need to see once when uploading it to Google Play, then Google will take care of it and use it to do the final signing of your apps after you've uploaded your app bundles.
Go to Player settings → Publishing Settings → Keystore Manager → Create new in dedicated location
You don't need to fill out everything. Just the password, key alias and key password. It doesn't matter what you call the key. Don't configure Unity to use this key just yet (we'll create another key and keystore for Unity to use shortly).
Follow instructions 1.-3. on Google Play to upload this new key using the pepk tool.
Then, you need to create an upload key and keystore. Unity will use this key to sign your app bundles. Again, do NOT use the instructions on Google Play to create this key, instead use the Unity UI to create another key store that plays nice with Unity.
The passwords and alias could be whatever you want I named my key uploadkey, but make sure to keep the key store and passwords somewhere safe, you will need these later, or you'll have to create new keys and talk to Google support to reset it.
When prompted, click yes to configure your project to use this new key.
When you've created the key store and key export its public key to the .pem format...
keytool -export -rfc -keystore upload.keystore -alias uploadkey -file upload_certificate.pem
...and upload it to Google Play.
Click Update and then Continue in Play Console.
Play store should now be ready to accept your .aab files.
Configuring Unity
Hopefully, your project is now set up to sign using the upload key you just created.
Make sure to set the package name yourself by going to Player Settings → Other Settings Override Default Package Name . Type in something appropriate in lower-case characters only, the default package name has uppercase characters, which I think is just begging for problems. You can't change this later, or you'll have to create a new play store entry, so make sure it's something that's acceptable for customers to see, i.e. com.yourcompany.gamename.
It's also a good idea to enable 64-bit builds in player settings otherwise, google play will complain later. Switch Scripting Backend to IL2CPP and then tick ARM64:
Tick Build App Bundle in Build Settings.
Click Build and build your .aab file
Then upload it to the Google Play Console:
If you're lucky, everything went smoothly, and you can click save and be ready to start testing your app.
If not, you may get helpful error messages, in which case just follow them, if not and they're really non-descriptive (like "Couldn't upload. Try again."), then try temporarily uploading an .apk instead, as that sometimes gives better error messages, then switch back to .aab when you've solved the issue.
In Unity 2020.3 you can use a jks upload key in Unity that was generated in Android Studio and keep "Let Google manage your key..." selected.
To generate a key, install Android Studio and create an empty Android Studio project then once gradle settles down, choose Build > Generate Signed Bundle. When it prompts for a keystore, create a new one and save it where you want. Cancel out, then in Unity select the jks you saved as your keystore in publishing settings.
You should be able to generate an aab package in Unity using the jks as a custom keystore to upload and still let Google manage the signing key like they recommend.
After struggling with uploading an app bundle, I realized one extra thing :
Don't use any forbidden characters in your password for the keystore in Unity ! This includes spaces and brackets, maybe not only...
If in doubt, try creating the key with Java keytool command line and it will tell you your password contains characters that can't work... Even just type the command line into a terminal and you'll see your password makes the command line break !
keytool -genkey -keystore yourfile.jks -dname "n=Mark Jones, ou=JavaSoft, o=Sun, c=US" -alias android -keypass YOUR PASSWORD -storepass YOUR PASSWORD -keyalg RSA -keysize 2048 -validity 2000
Maybe special chars are allowed in the Unity key generation panel but not in keytool ! Unity should fix this issue, it was driving me nuts ;)
Peace :)
FOR ALL YOU BEAUTIFUL FOLK WHO GET STUCK AT THE LAST STEP! - READ THIS!
Blockquote
When you've created the key store and key export its public key to the .pem format...
keytool -export -rfc -keystore upload.keystore -alias uploadkey -file upload_certificate.pem
...and upload it to Google Play.
Blockquote
Click Update and then Continue in Play Console.
THIS part drove me NUTS trying to figure out what the hell you meant by that. I know it's down to the fact that I'm a complete noob at this but the rest of the tutorial was AMAZING!
So let me clarify for those newbies (like me) who might lose the plot when they get to the last step and can't figure out what the hell to do.
At this point in the tutorial:
Blockquote
and upload it to Google Play. Click Update and then Continue in Play Console.
Here is what you have to do.
If you have already uploaded the FIRST signing key you were asked to make in unity (NOT the upload one), then simply go back to the INTERNAL TESTING page and refresh it.
Click CHANGE APP SIGNING KEY and then select the third option again: "Export and upload a key from Java keystore"
Click UPLOAD GENERATED ZIP and upload the .zip file that was created during the first steps.... I named mine output.zip
At STEP 4 you will see a link called "SHOW INSTRUCTIONS" - Click the link and upload your public upload certificate that was generated in the last step. The file ending with the .pem format
Click SAVE and it should work.
NOW the next part got me. I didn't know what to do from here. The project is ready to accept the .aab files but DO NOT DO THIS JUST YET!
Learn from Mr Impatient himself (that's me), read the rest of the tutorial. Changing the file name to all lowercase is good practice to prevent issues later with CamelCaseFileNames.
FINALLY
You might get an error that says your target Android API is too low. Simply go to the UNITY PROJECT > FILE > BUILD SETTINGS > PLAYER SETTINGS > OTHER SETTINGS > and half way down the page change MINIMUM API LEVEL to "31" or above as instructed by the Google Prompt you WILL get if you ignore this :)
You can do this through Unity, it will download the latest version of the Android SDK (it opens a powershell terminal - DO NOT CLOSE THIS).
Once that's done, and you've completed all the steps listed above, then and ONLY THEN are you ready to compile your .aab file and upload it to the Google Play Console.
Finally, I want to thank the author of this tutorial BobbaLuba for his amazing efforts. After 7 hours of messing around in Unity -> Android Studio -> Google Play and almost abandoning the thought of releasing my app on Google .... it worked!
You are amazing sir. I tip my hat to you. Keep doing what you do. I for one, am eternally grateful .... I am emotionally, mentally and physically drained. I'm off to bed. Thanks again!
Good luck my little code monkeys!
Peace out
- NewbNinja
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.
Google maps v2 is implemented in my app. It works fine when it is run with other computer.
But it is not showing Map when Apk is generated with my computer.
Is there any settings to change in my PC?. Please suggest me.
Google maps API key is generated with Signed key.
You are absolutely right you do not need to change the api key it is unique.
So you don't need to change anything in manifest.xml.
But, As you said when you run the project from your computer it does not showing the map. Because when you run the project by default it sign the apk with debug.keystore.
So now what you have to do is, just generate the SHA-1 from your pc using debug.keystore and make entry of that SHA-1 in google api console.
You can add multiple SHA-1 in your project settings at google api console.
Just see the screenshot you will got the idea.
when you run form your computer then debug.keystore used and when you create apk then keystore is change and also SH1 key is changed so your map is not show when you create apk.
Solution: create new api key for apk, use this key when you create apk. this link help you to get SH1 key from keystore
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.