I am new to Android Development. I have been creating an app that uses the Android Maps API. It was working well, until I updated my build tools and Android Studio. Now everytime I run it, my map is not shown, and I get the following error:
05-11 11:51:54.716 1535-1589/com.pruthvi.lanes I/OpenGLRenderer﹕ Initialized EGL, version 1.4
05-11 11:52:17.658 1535-1590/com.pruthvi.lanes E/b﹕ Authentication failed on the server.
05-11 11:52:17.658 1535-1590/com.pruthvi.lanes E/Google Maps Android API﹕ Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
05-11 11:52:17.668 1535-1590/com.pruthvi.lanes E/Google Maps Android API﹕ In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: AIzaSyA0QeeMrXpO06bvguCeF8iHFHWz3gwHrZw
Android Application (;): CC:8B:FA:E7:38:1F:A3:B6:93:A9:D7:EB:1E:2F:56:B9:F1:04:A0:FE;com.pruthvi.lanes
Here's a sample of my Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxwHrZw" />
<activity
android:name=".MapsActivity"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_maps" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LeftActivity"
android:label="Contacts" >
</activity>
<activity
android:name=".RightActivity"
android:label="Contacts" >
</activity>
<activity
android:name=".TopActivity"
android:label="Profile"
android:theme="#style/Theme.Transparent">
</activity>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
</activity>
And heres my Android Maps API file:
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at the end:
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=38:E4:08:5A:74:76:1E:21:32:DB:B2:EF:E9:3E:AD:C0:CF:15:64:73%3Bcom.pruthvi.lanes
You can also add your credentials to an existing key, using this line:
38:E4:08:5A:74:76:1E:21:32:DB:B2:EF:E9:3E:AD:C0:CF:15:64:73;com.pruthvi.lanes
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
-->
<string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">
AIzaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxwHrZw
</string>
I have tried numerous methods to solve the problem, but nothing is working. Any help would be great. Thanks!
Fine! Solved! My fingerprint was different in both the console and logcat. Used the one from the logcat and created a key, and now its working smooth. Thanks for the help Darko. Very much appreciated.
Do you have enabled Google Maps Android API (check on this link) and check if your key is valid (this link)
Related
I am trying to create a google maps activity using the google maps api in android studio. I generated the API key and pasted it in the google_maps_api.xml`. My manifest file is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.l5434.project">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<permission android:name="com.example.l5434.project" android:protectionLevel="signature"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name="pubsub.subscriber.MapsActivity"
android:label="#string/title_activity_maps"></activity>
<activity android:name="pubsub.subscriber.SubscriberActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I also added the dependency compile 'com.google.android.gms:play-services-maps:+' in my build.gradle but it didn't solve the problem.
This is how the emulator looks when the maps activity starts.
Do you know what's wrong?
This problem is usually related to the map API key used to sign manifest. Take a look at this post and this one which describe the same error you are experiencing. In both cases it is because the API key they used was created with the wrong keystore. You need to make sure you use your debug keystore when you create an API key in the Google API console
I set up the google api and run the app on a samsung device with google play services but nothing happened I had a withe screen withthe google logo on the buttom even if I had an internet connexion and activated the google location
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.myapplication" >
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<!--
The API key for Google Maps-based APIs is defined as a string
resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign
the APK.
You need a different API key for each encryption key, including the
release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in
src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name="com.example.android.myapplication.MapsActivity"
android:label="#string/title_activity_maps" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Api console.
the MapsActivity code
Make sure API key is not restricted for Android Apps, By default it is restricted
you can enable it from here
I'm having issues with google maps, I have got it working with the debug key but when try the release version, I'm getting a blank screen instead of the map. I've followed instructions and signed the release key.
C:\Program Files\Java\jre1.8.0_25\bin>keytool
-list -v -keystore C:\DecSurfApp\key.jks
Gives me this key:
SHA1: B6:1F:24:AB:##:8A:C9:EF:C9:##:##:##:##:##:##:##:##:##:##:##
Which I've used to generate api key
B6:1F:24:AB:##:8A:C9:EF:C9:##:##:##:##:##:##:##:##:##:##:##;
com.nitinarya.surfalarmclockrelease
What am I doing wrong?
Edit: Added AndridManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name="com.nitinarya.surfalarmclockrelease.MapsActivity"
android:label="#string/title_activity_maps" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
google_maps_api.xml
<resources>
<string name="google_maps_key_instructions" templateMergeStrategy="replace"><!--
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
--></string>
<string name="google_maps_key" templateMergeStrategy="preserve">####################3PvXCg</string>
I think there is a problem with wrong Google API key. So you need to use SHA fingerprint while you are going to release your app.
For example , after final deployment of your application you can able to find SHA finger print while you'r going to finish (generate apk) so use that SHA finger print and generate google map key and add it to your manifest file and run once. After that just release your apk and deploy it. It will show you google map.
NOTE: Also check that you have added all necessary information to your Androidmanifest.xml file.
In my app i use google sample in my eclipse and use code basic map.java but when i run my app crash and down!
When I use step by step with google show map tutorial this link:
https://developers.google.com/maps/documentation/android/start?hl=pt-ZA
No problem.
My min Sdk:10 And target Sdk 19 and compile:19
my LogCat:
06-07 01:23:11.180: W /GooglePlayServicesUtil(1813): Google Play services is missing.
But I installed Google play services!
There can be two scenarios
Project must be imported google play services.
In the AndroidManifest must have
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" /> in the child of <application> tag.
Edited :
AndroidManifest.xml
<application <!-- Application Tag -->
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data <!--child of application tag -->
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAvGvbXJD4N5PC_YT2EvdcPgP9mx9YCMs4" />
<!-- activity declarations -->
<activity
android:name="com.sample.MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" >
</activity>
If you are using an actual device then you also need to have the Google Play Services app installed on the device. You can download it from Google Play: https://play.google.com/store/apps/details?id=com.google.android.gms
I've been developing my first android app using Google Maps SDK.
It work perfectly fine when i Run the application with Android Studio using my Samsung Galaxy S4. I can see maps, everything is good.
Now today, i released, and i testet it on my friends Samsung Galaxy s4. It did not show any maps. What a nightmare. What must i do? What information do i need to provide so someone can help me out?
Edit:
I signed my apk with android studio. It create some .jks file.
Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<permission
android:name="de.christianbergau.gojogging.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="de.christianbergau.gojogging.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:debuggable="false"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MYAPIKEYHERE" />
<activity
android:name="de.christianbergau.gojogging.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="de.christianbergau.gojogging.SessionsActivity"
android:label="#string/title_activity_sessions" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="de.christianbergau.gojogging.MainActivity" />
</activity>
<activity
android:name="de.christianbergau.gojogging.MapActivity"
android:label="#string/title_activity_map" >
</activity>
<activity
android:name="de.christianbergau.gojogging.SettingsActivity"
android:label="#string/title_activity_settings" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="de.christianbergau.gojogging.MainActivity" />
</activity>
</application>
You were all right, this is what i did:
I did create an API Key with my debug.keystore SHA1 fingerprint.
I did create an APK file and signed it with my .jks file which android studio did create for me
I did deploy that APK and Maps could not be displayed
To fix it:
Get the SHA1 fingerprint of the jks file with the following command:
keytool -v -list -keystore /path/to/my.jks
Created new API Key on Google
Saved new API key to my manifest.xml
Upload new APK
Done
When you run app with Android Studio, your app use debug.keystore. Map work because map key generated for debug.keystore. You must generate api key for your release keystore.
When you publish your app with debug key, map looks blank. Use release key for production.
You can check this.
Google Map Android API v2 can't display map in play store application