Google Maps API access release - android

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.

Related

Android Studio-Google maps doesn't show map

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

Google Maps not shown in the release mode

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.

Android SDK Google Maps does not show map in "production mode"

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

Google Maps Android V2 - Blank Screen

I am implementing google maps for android. I created a test application and inserted all the permissions etc in that application and the application worked flawlessly.
But when I try and copy the same code to my real application it shows me blank screen on the android activity.Although I've updated the package name in the google api console.
Here's what my Test Project Manifest Looks Like :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapstutorial"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.example.mapstutorial.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.mapstutorial.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-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my api key"/>
<activity
android:name="com.example.mapstutorial.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>
</application>
</manifest>
and here's what my real project manifest looks like :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shop.shoppinglist"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<permission android:name="com.shop.addtask.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<permission android:name="com.shop.shoppinglist.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<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="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.shop.addtask.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.shop.shoppinglist.permission.C2D_MESSAGE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:allowBackup="true"
android:theme="#style/AppTheme" >
<uses-library android:name="com.google.android.maps"/>
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="my api key"/>
<activity
android:name=".Login_Activity"
android:label="#string/title_activity_main"
android:theme="#style/Theme.Sherlock"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I updated the package name to com.shop.addtask in my console fingerprint but still it shows me the white screen.What could cause the problem ? The apikey I've used is same in both of the applications. But it works on test application not on the real app.
I've created the api key using the fingerprint
I've switched on google maps android v2 in the console
I am using the same api key as mentioned in the console.
So these things are correct and the problem cannot be caused by one of them.
2 possible reasons:
1. this part:
<uses-library android:name="com.google.android.maps"/>
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="my api key"/>
should right before the closing application tag.
2. Most likely you have some sort of problem with your key. Try to generate a new by deleting the debug.keystore folder and running a project. then register it again via the console.
you can use this guide I wrote to do just that:
Google Map API V2 key
Update:
Check this for a second:
<permission android:name="com.shop.addtask.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
it looks that the package you set here is not the package of your application and should be:
<uses-permission android:name="com.shop.shoppinglist.permission.MAPS_RECEIVE"/>
<permission android:name="com.shop.shoppinglist.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<permission android:name="com.shop.addtask.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.shop.addtask.permission.MAPS_RECEIVE"/>
package name is
package="com.shop.shoppinglist"
Hope below link helps you, AndroidManifest.xml for Google Maps Android API v2
try this,
<permission android:name="com.shop.shoppinglist.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.shop.shoppinglist.permission.MAPS_RECEIVE"/>
After everything fails, try to uninstall the app and try it again. It worked in my case.
My problem was that I've changed the app's package name in the AndroidManifest file, but not the gradle.build's "applicationId" property, maybe that helps someone...
I had the same problem. I tried everything suggested on the different solutions on this error. Inclusively, I recreated my API key(including creating a new project) and nothing worked. After many, many hours wasted, I decided to delete all myapp user data on my android device, and magically this took care of the problem. My maps display correctly! Yay!!!
Android 4.2.2: Settings/Apps/YourApp/Clear data.
I hope this simple solution helps when everything else fails.
ok, I have the same problem, I follow all the steps in the blogs and the google official page and not working, the solution is correct
<uses-library android:name="com.google.android.maps"/>
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="my api key"/>
before close the application tag, but in the other case I found the solution, the problem is I generate SHA1 code in a macinthosh but I clone the repository and work in windows plataform but I found this problem, my solutions is that go to google console and generate other apikey but get the SHA1 code using this comand in windows,open the console
and typed this code
cd C:\Program Files\Java\jre1.8.0_20\bin and press enter
next step copy and paste this code
keytool -list -v -keystore %HOMEPATH%\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android
after press enter inside the console you show the SHA1 code copy and paste in a google console,is very important specified SHA1 code ";" and correct package ..
regards!!!
I 've got a similar problem with the map. After fixing all lib and key problems, I just saw a white sreen labled with "Google".
The problem was, that I put the MapFragment into a ScrollView. After removing the ScrollView everything works fine. I can see the map.
Check whether you enabled Google Maps Android API or not
Open Google Map developer console.
Go to Library -> Google Maps Android APIs
If it is disabled, enable it.

Google MapActivity not displaying map

I am trying to get google maps working. It is not displaying the map. I get the following error in LogCat
Couldn't get connection factory client
I have been through all the duplicate posts, and made the following changes
Ensured that uses-permission and uses-library are inside tag
used debug.keystore instead of custom
signed up with google maps using my private key, and updated my MapView with the maps key in the xml (for this public post, I have changed it)
Exported my app, and used debug.keystore to build it
I am running it on emulator. Maps on emulator works.
Android Manifest
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<uses-library android:name="com.google.android.maps" />
<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.READ_PHONE_STATE"/>
<activity
android:name=".MyActivity"
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=".GetLocation" android:label="#string/app_name"/>
</application>
location.xml
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0psLgKtDQLB35-XJXUrjR4bKHIBDRuHu-O-xVhg"
android:id="#+id/location"
/>
sudo keytool -list -alias androiddebugkey -storepass android -keypass android -keystore debug.keystore
returns
androiddebugkey, 20 Mar, 2012, PrivateKeyEntry,
Certificate fingerprint (MD5): 20:D3:54:D9:F8:70:17:A4:BA:21:5C:98:88:27:45:E0
Fixed
I put uses-permission outside of Application tag
And uses-library inside of Application tag
uses-permission outside the <application> Tag. and
Couldn't get connection factory client
And its map-api key problem .And you should create Fresh Map-api key .
I believe you might have got the solution for this question but for anyone else looking for the help for same question here's the ans
try to put
<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"/>
outside your application tag
just leave
<uses-library android:name="com.google.android.maps" /> inside the tag
add metadata inside the application tag as
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="your API key"/>
and it will definitely work fine

Categories

Resources