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
Related
The app debug works fine but in the release doesnt work.
Here is the AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.poldevs.pabloelmapas">
<!--
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="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCPHx0_******"/>
<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/Theme.AppCompat.NoActionBar">
<activity android:name=".ChatGlobalActivity"></activity>
<activity android:name=".fotoperfil" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="#string/title_activity_maps" />
<activity android:name=".ChatActivity" />
<activity android:name=".Mapa_Activity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I hava tried creating different API keys from google, both works on debug version but not in release, the map doesnt load.
Also I have a key for the debug version and another key for the release version (I have tried with the same key but still not working.
Have you generated the release key for google map. follow this link to generate a release key for google map.
Before publishing application into play store you have to follow some step to create release key with your app signing keystore.
An app that works in debug mode but not release mode can sometimes indicate a proguard problem. Did you try disabling proguard in build.gradle?
buildTypes {
release {
minifyEnabled false
}
}
If the app works with this change, then you'll need to modify your proguard config file.
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
My question is common, but I have tried all the suggestions listed before to solve the issue of that Google Maps only shown in debug mode not in release mode.
The below have been tried (for sure I have used the SHA-1 certificate fingerprint for debug keystore and release keystore as per google documents):
Added different api Keys in the google_map_api.xml for debug and
release.
Added same key for both debug and release modes.
Write the key manually in thee Manifest.xml
Refer to the string in the Manifest.xml
Update:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<!--
The API key for Google Maps-based APIs.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name="local.application.user.myApp.MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Go to your Google api console where select the app and in left side :
Release management=> App Signing=> copy SHA-1 certificate inside App signing certificatemodule and paste into the Google cloud console and add this SHA1 with your project and save it . it will work . it works me.
After trying all suggested solutions (Thx for everyone). I tried to disable the Google Maps Api and re-enabled it again (from console.developers.google.co) and it has been working fine since then.
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)
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.