Google MapActivity not displaying map - android

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

Related

Google Maps API access release

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.

Google Maps API V2 blank map after installation on real device

When I emulate the app from eclipse using the device everything's OK, but after I generate the apk file and have it installed, my map is blank.
I followed these steps:
Generate a new keytool
keytool -genkey -v -keystore my-keystore-name.keystore
-alias myKey1 -keyalg RSA -keysize 2048 -validity 20000
From Eclipse I "Export signed application package" using the keystore file (and key) I got from step 1.
Copy the apk to the device and select "package installer"
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="apt.login"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<permission
android:name="apt.login.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission
android:name="apt.login.permission.MAPS_RECEIVE"/>
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<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.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:permission="android.permission.WRITE_EXTERNAL_STORAGE"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:testOnly="false"
android:debuggable="true">
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="apt.login.UIactivity.Login"
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="apt.login.UIactivity.Loading">
</activity>
<activity
android:name="apt.login.UIactivity.Mapa">
</activity>
<activity
android:name="apt.login.UIactivity.Splitbar"
android:label="#string/app_name" >
</activity>
</application>
</manifest>
You should try moving the <meta-data/> containing your API KEY to just before the closing tag.
You also don't have the following in there and you should:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
Why don't you create a new key from eclipse, Android Tools -> Export signed package, create new keystore.
Generate the SHA-1 key, use it to get the API key and place it in the meta data present in manifest file
Use the keystore that you use for create .apk file of your project.
Open terminal and write below command keytool -list -v -keystore your_keystore_name -alias your_alias_name after your press enter it will ask you for password give your keystore password. press enter. it will genrate MD5 key & SHA1 key.(key like this)
SHA1: BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:90:AF:A1:66:6E:44:5D:75
use this SHA1 key in googleconsole when you creating browser key for map.
This is work for me.

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

Using Google Maps v2 in Android

i am trying to integrate Google Maps to my Android Application. I followed this tutorial: https://blog-emildesign.rhcloud.com/?p=435.
I did everything as suggested.
These are the errors in the error log:
E/Google Maps Android API(28238): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
E/Google Maps Android API(28238): Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
E/Google Maps Android API(28238): Ensure that the following correspond to what is in the API Console: Package Name: com.example.kontrollen, API Key: xxxxxxxxxxxxxx, Certificate Fingerprint: xxxxxxxxxxxxxxxxxxxxxxx
And this is my google account:
Do you have any ideas what i can do?
This is my AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.kontrollen"
android:versionCode="1"
android:versionName="1.0" >
<permission android:name="com.example.kontrollen.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.example.kontrollen.permission.MAPS_RECEIVE"/>
<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"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxx" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.kontrollen.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>
I solved the problem by uninstalling the app and cleaning the project folder. I did not change anything. Thank you for your help.
follow the url to create your app google api key i have done this recently.. and it was successful.
https://code.google.com/apis/console/ ------------ For Google API
https://developers.google.com/maps/documentation/android/start ------------ Crate Map
read these page carefully every thing is given in this page .. follow the same but make sure you have generated correct SHA1 fingerprint
and when you are going to crate the app make sure run it on real device because it need google play services to run add google pay services in your application
Edited answer:
Try putting the meta-data within the application tag, preferably right before the closing tag like
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xyz" />
</application>
Follow this steps to trace error youself
STEPS
for your error type
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
1.check for internet or gsf reader permissions in manifest as shown above.
2.check for the package name you used in you manifest.
3.check in your api console the service that you started is Google Maps Android API v2.
4.Check the library google play services is imported or not.
5.if no solution is working try out new way following this link-- https://developers.google.com/maps/documentation/android/start.
6.Also keytool command to generate sha1--i used is-
keytool -v -list -alias androiddebugkey -keystore C:/Users/username/.android/debug.keystore
I had actually made a maps activity from the studio and used the link it generated to set up the maps API. Where I went wrong was, I placed it inside a package and the package name that was registered for the app was with that folder name. For Ex.
If app package name is
com.awesome.shit
the package that was saved in API was
com.awesome.shit.maps
changed it and it started working.

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.

Categories

Resources