java - Android: Google Maps v2 API loading blank map on Android 4.0 and above -


i using google maps android v2 in android project.

i have tested on 3 devices: htc vivid (4.0.3), asus nexus 7 (4.2.2), , galaxy s2 (2.2). map shows on galaxy s2 using above information, know should work fine.

question: need add compatibility, or fix errors higher api versions?

i have done following:

  • generated keystores (both debug , custom) , registered both of sha-1 codes package name google apis console. have tried program both api keys , both returned same blank screen , error. using program out of debug mode shows attempts made access api in report logs in console.
  • imported android-support-v4.jar file
  • imported google-play-services_lib project folder, set library, , configured project use library.
  • set "my_map.xml" layout following code

    <?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" /> 
  • set activity class following code

    import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.supportmapfragment; import com.google.android.gms.maps.model.latlng; import com.google.android.gms.maps.model.markeroptions;  import android.os.bundle; import android.view.menu;  public class mapactivity extends android.support.v4.app.fragmentactivity {  @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.my_map);  googlemap map =              ((supportmapfragment)getsupportfragmentmanager()             .findfragmentbyid(r.id.map)).getmap(); map.addmarker(new markeroptions().position(new             latlng(34.739849,-92.307129)).title("swagstring")); }  @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.map, menu); return true; } } 
  • i have required permissions
  • i have added meta-data key androidmanifest.xml

  • permissions:

    <permission android:name="com.uaex.droughtadvisor.permission.maps_receive" android:protectionlevel="signature" />  <uses-permission android:name="com.uaex.droughtadvisor.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-feature     android:glesversion="0x00020000"     android:required="true" /> <uses-permission android:name="android.permission.access_wifi_state"/> 
  • meta-data

    <meta-data     android:name="com.google.android.maps.v2.api_key"     android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" /> 
  • upon running code on 4.0 , above devices, error:

    failed load map. error contacting google servers. 

i'm not sure was, got working. targeting 2.2, downloaded other versions in sdk manager , tried (just 4.0.3 , 4.2.2, versions of test devices). targeted , installed them on respective devices , worked. moving down 2.2, still worked, when didn't. no idea happened here, i'm fine now.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -