As I open my app, the only thing the MapView shows is the map of the world (a part of it) loading really really slowly. The resolution is low, I can't zoom in and see strees, road, etc. Basically, everything is just pixelated, and when I zoom in the map doesnt even load, I can only see the grid.
I tried many things, yet nothing works. Any suggestions?
I checked my API key many times and even generated a new one.
I did restrict my key.
I granted all the required permissions.
I'm pretty sure that my code is fine, but i'll post it anyway.
//The map code
public void LoadMap()
{
if (IsGoogleApiAvailabe())
{
MapFragment mMapFragment = MapFragment.NewInstance();
FragmentTransaction fragmentTransaction = FragmentManager.BeginTransaction();
fragmentTransaction.Add(Resource.Id.fragment_container, mMapFragment);
fragmentTransaction.Commit();
mMapFragment.GetMapAsync(this);
}
}
//Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="com.example.android.porject">
<permission
android:name="com.example.android.PCP.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.example.android.PCP.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<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"/>
<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="#mipmap/ic_launcher"
android:label="P.C.P"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data
android:name = "com.google.android.maps.v2.API_KEY"
android:value = "#string/GoogleKey" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
What am i missing?
Apparently this whole time I have been using a wrong SHA-1. Don't do this mistake: For some reason, the SHA-1 from the Android Studio Google Maps project was wrong- as explained in most of the Google Maps tutorials as the easiest way to get this fingerprint. The alternative ways to get the fingerprint:
In the debug output window of VS, while debugging the application, search for "keystore certificate" right under those instructions in the output window: Authorization failure. Please see developers.google.com/maps/documentation/android-api/start for how to correctly set up the map. In the Google Developer Console (console.developers.google.com) Ensure that the "Google Maps Android API v2" is enabled. Ensure that the following Android Key exists: {KEY}".
I haven't tried this option yet, but use the following command to get the fingerprint::keytool -list -v -keystore mystore.keystore
Related
Though I know this has been a persistent and addressed issue, everyone's problem seems to be solved a different way every time. I have been trying to get my map to show all day but to no avail. I had a project which had a map in it, so what I migrated that project to another location and set up Google Play Services in that project. I got everything to work except for the map to show. I have the library as i am able to use LatLng but the map always fails to load. I have generated new keys, deleted and re added the key, and deleted and re added the debug keystore. I have also updated the api console to ensure everything lined up but my map still doesnt show. I have Google Map for Android Api enabled in the console. And my package name is correct also. I have ran a clean rebuild and uninstalled the app to see if it works but it still doesnt load.
NOTE: I have also tried using SupportMapFragment instead.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.wallfly"
android:largeHeap="true">
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Actionbarstyle">
<activity
android:name="com.android.wallfly.MyActivity"
android:label="#string/app_name" >
</activity>
<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="(Actual API Key)" />
</application>
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<permission
android:name="com.android.wallfly.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.android.wallfly.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.WRITE_SETTINGS" />
<!-- these grant the app the ability to access location. coarse is wifi and cellular, fine is gps -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
I have added an image to show that my package name lines up. Also i copied and pasted the SHA1 fingerprint so I am sure that it does line up also.
For those who may face a similar problem, my google play service was outdated. So I had to change the build.gradle the current version of google play service.
I'm unable to get google maps api v2 to display anything more than a blank screen in my Android Xamarin application.
In logcat, I get the following error.
07-08 16:08:12.192: E/Google Maps Android API(28625): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
This makes me believe it is a problem with my API key. I don't know what I'm missing though. Here is my AndroidManifest.xml.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="2" android:versionName="2.0.0.0" package="com.deg.blubcnmobl.droid">
<uses-sdk android:targetSdkVersion="12" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<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.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<permission android:name="com.deg.blubcnmobl.droid.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<uses-permission android:name="com.deg.blubcnmobl.droid.permission.MAPS_RECEIVE" />
<application android:icon="#drawable/logo" android:debuggable="true" android:enabled="true" android:persistent="false" android:allowClearUserData="true" android:theme="#android:style/Theme.Black.NoTitleBar">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="MY_KEY" />
</application>
</manifest>
Here is my activity axml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
class="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/mapfragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
I have Google Maps Api V2 Android turned on in API settings.
Here is the page where I created the API key.
Make sure you add these permissions to the manifest
<permission
android:name="com.deg.blubcnmobl.droid.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.deg.blubcnmobl.droid.permission.MAPS_RECEIVE"/>
You seem to be missing a number of permissions in your manifest.
Sample manifest for Maps V2 capable of running on API level 8 and upwards
https://github.com/ddewaele/GoogleMapsV2WithActionBarSherlock/blob/master/GoogleMapsV2SkeletonV8/AndroidManifest.xml
Sample layout for Maps V2 capable of running on API level 8 and upwards
https://github.com/ddewaele/GoogleMapsV2WithActionBarSherlock/blob/master/GoogleMapsV2SkeletonV8/res/layout/activity_main.xml
Sample activity for Maps V2 capable of running on API level 8 and upwards
https://github.com/ddewaele/GoogleMapsV2WithActionBarSherlock/blob/master/GoogleMapsV2SkeletonV8/src/com/example/googlemaps/v2/skeleton/api8/MainActivity.java
You can clone the git repository above and try the complete GoogleMapsV2SkeletonV8 application.
Please check this post: Google Map Android Api V2 Sample Code not working, if you are completely sure you did the right steps and still see the blank screen then follow the second answer, the authentication gets cached somewhere, try to uninstall the application manually (just like you do with a normal application) then "Run" again the project.
I have given an answer of it at https://forums.xamarin.com/discussion/26058/google-map-is-showing-a-blank-screen-in-android
Application just displays a plain skin colored screen instead of a mapView.
I have tried followings :
I have followed all the steps from this docs.
I have enabled Google Maps Android API v2 in Google API console.
I have generated an API key for android. Also tried creating several times. Even on different machine.
I have added Google play services to my project.
I tried setting Custom debug keystore to Default debug keystore.
My AVD target is set to Google APIs level 17.
Manifest.xml file :
<permission
android:name="com.objectlounge.ridesharebuddy.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.objectlounge.ridesharebuddy.permission.MAPS_RECEIVE"/>
<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.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<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" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="API_KEY"/>
<uses-library android:name="com.google.android.maps"/>
My activity and layout files are same as in this docs.
I use emulator. I am not sure if android mapView v2 is supported in emulator.
Any idea what is the problem?
Make sure your activity extends a FragmentActivity instead of Activity.
And replace you xml layout fragment with the following one:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
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.
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.