MapView not getting displayed - 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" />

Related

Google Maps API MapView doesn't fully load

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

Google maps doesn't load prop

i have followed the google tutorial for using google maps and every thing is fine except that the map doesn't load prob on genymotion emulator
this is my mainfest
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<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"/>
<!-- The following two 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.geo.API_KEY"
android:value="*************************************"/>
<activity
and this is my layout
<?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"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
please respond asap !!!
If you are under developing your project, the API key which you are currently using must be generated from your PC's SHA key.
If it is fine, there could problem in your Play services. So, the Google Play Services must be in upto date.
Thanks!!

Google map not loading Android

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.

Google Maps Api v2 Xamarin blank screen

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

Google maps problem - not start

Sorry if question is stupid but I am new to android, I need to put map in my android app. I looked at net and I run keytool.exe and get key, but when I run app it crushed and
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0WR3Cl0evv0U6G2xH9ZnvEFYbDiSDUu_GRovTUQ"
/>
</RelativeLayout>
I don't know what is wrong. I put in manifest in application tag , like I saw on net. Is that all I need to do or I make something wrong ? Did I escape some step ?
In the manifest file, you might have forgotten to put the "internet" permission.
You have to use library in manifest file.
You have to Google API add-ons.
You have to be very precise while choosing the build target type (android version).
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<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"/>
Put all these permission in your manifest file
and in tag put these lines as a child
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCzlSw2fSYPx--CgFpk0LBp8Ofm23glhCs"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"
/>

Categories

Resources