somerandomusername
somerandomusername

Reputation: 2035

Google map not loading data

I'v set up google maps in my application, it went smooth and without errors, but map is just not loading any content. Cat log says it uses "Google Play services client version: 4452000" and right after that "Google Play services package version: 5089038" , is that normal?

This is what it looks like:

enter image description here

    FragmentManager fmanager = getSupportFragmentManager();
    Fragment fragment = fmanager.findFragmentById(R.id.map_view);
    SupportMapFragment supportmapfragment = (SupportMapFragment)fragment;
    GoogleMap supportMap = supportmapfragment.getMap();

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/map_view"
              android:layout_width="match_parent"
              android:layout_height="400dp"
              android:name="com.google.android.gms.maps.SupportMapFragment"/>

I/Google Maps Android API(23503): Google Play services client version: 4452000
I/dalvikvm(23503): Could not find method gui.a, referenced from method gqh.a
W/dalvikvm(23503): VFY: unable to resolve static method 24934: Lgui;.a (Landroid/content/Context;)Lgrh;
D/dalvikvm(23503): VFY: replacing opcode 0x71 at 0x0003
E/dalvikvm(23503): Could not find class 'gpq', referenced from method gpr.a
W/dalvikvm(23503): VFY: unable to resolve new-instance 4090 (Lgpq;) in Lgpr;
D/dalvikvm(23503): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm(23503): Could not find class 'gpq', referenced from method gpr.a
W/dalvikvm(23503): VFY: unable to resolve new-instance 4090 (Lgpq;) in Lgpr;
D/dalvikvm(23503): VFY: replacing opcode 0x22 at 0x0000
E/dalvikvm(23503): Could not find class 'gpq', referenced from method gpr.a
W/dalvikvm(23503): VFY: unable to resolve new-instance 4090 (Lgpq;) in Lgpr;
D/dalvikvm(23503): VFY: replacing opcode 0x22 at 0x0000
D/dalvikvm(23503): DexOpt: unable to opt direct call 0x5ea1 at 0x0a in Lgpr;.a
D/dalvikvm(23503): DexOpt: unable to opt direct call 0x5ea1 at 0x0c in Lgpr;.a
D/dalvikvm(23503): DexOpt: unable to opt direct call 0x5ea1 at 0x0a in Lgpr;.a
D/dalvikvm(23503): GC_FOR_ALLOC freed 433K, 9% free 19472K/21336K, paused 13ms, total 13ms
I/Google Maps Android API(23503): Google Play services package version: 5089038
W/dalvikvm(23503): VFY: unable to resolve static field 20875 (t) in Lyo;
D/dalvikvm(23503): VFY: replacing opcode 0x62 at 0x000e
W/dalvikvm(23503): VFY: unable to resolve static field 20875 (t) in Lyo;
D/dalvikvm(23503): VFY: replacing opcode 0x62 at 0x000d
D/dalvikvm(23503): GC_FOR_ALLOC freed 585K, 8% free 19817K/21336K, paused 13ms, total 13ms
I/dalvikvm(23503): Failed resolving Lcom/google/android/gms/location/internal/ParcelableGeofence; interface 4023 'Lglm;'
W/dalvikvm(23503): Link of class 'Lcom/google/android/gms/location/internal/ParcelableGeofence;' failed
E/dalvikvm(23503): Could not find class 'com.google.android.gms.location.internal.ParcelableGeofence', referenced from method gls.a
W/dalvikvm(23503): VFY: unable to resolve check-cast 2086 (Lcom/google/android/gms/location/internal/ParcelableGeofence;) in Lgls;
D/dalvikvm(23503): VFY: replacing opcode 0x1f at 0x0019
D/dalvikvm(23503): GC_FOR_ALLOC freed 155K, 4% free 20608K/21336K, paused 13ms, total 14ms
V/QcrilMsgTunnelSocket( 1866): After reading offset = 0 remaining = 4 countRead = 4
D/QcrilMsgTunnelSocket( 1866): messageLength extracted from first 4 inputStream reads = 29
V/QcrilMsgTunnelSocket( 1866): offset = 0 remaining = 29 countRead = 0
V/QcrilMsgTunnelSocket( 1866): offset = 0 remaining = 29 countRead = 29
D/QcrilMsgTunnelSocket( 1866): readRilMessage: Buffer = [B@425f22a0 HexData = [0100000004040000110000005155414c434f4d4def0308000100000003]
V/QcrilMsgTunnelSocket( 1866): Read packet: 29 bytes. Data Available = 32 Position = 0
D/QcrilMsgTunnelSocket( 1866): processResponse. message type = 1. Data Available = 28
D/QcrilMsgTunnelSocket( 1866): ByteArray from parcel = 5155414c434f4d4def0308000100000003
D/QcrilMsgTunnelSocket( 1866): Received RIL_UNSOL_OEM_HOOK_RAW message
D/QcrilMsgTunnelSocket( 1866): Oem ID in RIL_UNSOL_OEM_HOOK_RAW is QUALCOMM
D/QcrilMsgTunnelSocket( 1866): OEM ID check Passed
D/QcrilMsgTunnelSocket( 1866): Response ID in RIL_UNSOL_OEM_HOOK_RAW is 525295
D/QcrilMsgTunnelSocket( 1866): Response ID 525295is not served in this process.
D/QcrilMsgTunnelSocket( 1866): To broadcast an Intent via the notifier to external apps
D/QcrilMsgTunnelIfaceManager( 1866): handleMessage what=0
D/QcrilMsgTunnelIfaceManager( 1866): Broadcasting intent ACTION_UNSOL_RESPONSE_OEM_HOOK_RAW
V/QcrilMsgTunnelSocket( 1866): Before reading offset = 0 remaining = 4 countRead = 0
I/Google Maps Android API(23503): Failed to contact Google servers. Another attempt will be made when connectivity is established
D/MobileDataStateTracker(  785): default: setPolicyDataEnable(enabled=true)
E/Google Maps Android API(23503): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

Upvotes: 0

Views: 613

Answers (3)

Karim
Karim

Reputation: 786

You need another API key to use while testing. its different from the API key you generated from keystore file.

From eclipse-->windows-->Preferences-->Android-->Build. Use this SHA1 fingerprint and get another API key from Google API console and use it for testing.

Don't forget to change it to the production one before uploading the APK to google play.

Update: I use this way and it works fine. Its different from the one you use:

fragment_map.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <com.google.android.gms.maps.MapView
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</RelativeLayout>

this is my MapFragment Class. I locate a point on the map and give it a title:

public class MapFragment extends Fragment  {

    final static String TAG = "map"; 
    final static String LONG = "long"; 
    final static String LAT = "lat"; 
    final static String TITLE = "title";

    private MapView mMapView;
    private GoogleMap mMap;
    private Bundle mBundle;
    Bundle args;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View inflatedView = inflater.inflate(R.layout.fragment_map, container, false);

        MapsInitializer.initialize(getActivity());

        mMapView = (MapView) inflatedView.findViewById(R.id.map);
        mMapView.onCreate(mBundle);
        setUpMapIfNeeded(inflatedView);



        return inflatedView;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBundle = savedInstanceState;
        args = getArguments();
    }

    private void setUpMapIfNeeded(View inflatedView) {
        if (mMap == null) {
            mMap = ((MapView) inflatedView.findViewById(R.id.map)).getMap();
            if (mMap != null) {
                setUpMap();
            }
        }
    }

    private void setUpMap() {
        mMap.addMarker(new MarkerOptions().position(new LatLng(args.getDouble(LAT), args.getDouble(LONG))).title(args.getString(TITLE)));
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(args.getDouble(LAT), args.getDouble(LONG)), 15));
    }


  @Override
    public void onResume() {
        super.onResume();
        mMapView.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
        mMapView.onPause();
    }

    @Override
    public void onDestroy() {
        mMapView.onDestroy();
        super.onDestroy();
    }



    @Override
    public void onStart() {
        super.onStart();
    }
}

And this is how I add it to the screen:

        MapFragment mapFragment = new MapFragment();
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        Bundle args = new Bundle();
        args.putString(MapFragment.TITLE, title);
        args.putDouble(MapFragment.LONG, longitude);
        args.putDouble(MapFragment.LAT, latitude);
        mapFragment.setArguments(args);
        transaction.replace(R.id.content_frame, mapFragment,"map");
        transaction.addToBackStack(null);
        transaction.commit();

I hope it helps.

Upvotes: 1

as per my understanding this issue is happening because of three reason

Reasons 1) first is lack of internet connectivity

2) second is your google api key is missmatching

3) third if key is ok then your provided package name during key generation is not exact same as your project package name

Solutions for first you need to check your internet conncetion is working or not then you need to go further

for second and third you need to create key with proper steps If your using eclipse then

Eclipse-->windows-->Preferences-->Android-->Build you will get SHA key

Use that SHA key to generate your android key

after pasting SHA key append your project package name by following symbol ";"

for example

YOR_SHA_KEY;YOUR_PROJECT_MAIN_PACKAGE_NAME then generate key finally you will get google map key for android use that one hope it will resolve your problem make sure that your using same pakcage name which is your project package name

hope it will solve your problem happy coding :)

Upvotes: 0

DRY Believer
DRY Believer

Reputation: 1018

Try the below code . this worked for me...

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:map="http://schemas.android.com/apk/res-auto"
    android:name="com.google.android.gms.maps.MapFragment"
    android:id="@+id/thapar_map"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>



setContentView(R.layout.maps);
        GoogleMap map;
        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.thapar_map)).getMap();
        map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
        map.setPadding(5, 5, 5, 5);
        map.setMyLocationEnabled(true);

Upvotes: 0

Related Questions