Search code examples
androidandroid-maps-v2supportmapfragment

Google Maps Android API v2 works only on one phone


I'm working with my team on getting Google Maps to display using their Android API v2.

I managed to get the codes up and tested on my own phone and it works perfectly... however when the codes run on my teammates' phones, their screens are grey, and they have this:

E/Google Maps Android API(30514): Authorization failure.

The weird thing is, this error doesn't appear in their logcat 100%, sometimes they just get the grey screen without any errors. Our codes are sychronized with SVN by the way so they are definitely updated.

My API key is obtained from the debugging key, and has been verified to be correct since it runs perfectly on my phone.

I'm not sure what exactly is causing this and thus I'm not sure what codes I can post here to seek help. In the meantime I'm going to post my MapFragment class codes and hope it sheds some light for someone to help.

Please let me know if there's anything else I can post up here to seek an answer and I'll post it asap. Thanks!

public class POnlineMapViewFragment extends SherlockMapFragment {

    private GoogleMap mMap;
    private double latitude;
    private double longitude;
    private String placeName;
    static Bundle bundle;
    private LatLng point;
    View v;

    @Override
    public void onCreate(Bundle savedInstanceState) {    
        super.onCreate(savedInstanceState);
        bundle = getArguments();
        if(bundle != null) {
        this.latitude = getArguments().getDouble("latitude");
        this.longitude = getArguments().getDouble("longitude");
        this.placeName = getArguments().getString("placeName");
        this.point = new LatLng(latitude,longitude);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle savedInstanceState) {
        View v = super.onCreateView(inflator, container, savedInstanceState);
        mMap = getMap();

        CameraUpdate center= CameraUpdateFactory.newLatLng(point);
        CameraUpdate zoom=CameraUpdateFactory.zoomTo(17);
        mMap.addMarker(new MarkerOptions().position(point).title(placeName).icon(BitmapDescriptorFactory.fromResource(R.drawable.gps_small)));


        mMap.moveCamera(center);
        mMap.animateCamera(zoom);

        return v;     

    }

    public static POnlineMapViewFragment newInstance(Bundle b) {
        POnlineMapViewFragment mapfrag = new POnlineMapViewFragment();
        mapfrag.setArguments(b);
        return mapfrag;
    } 
}

Solution

  • To use the map you need map api key from google, by providing fingerprint of your keystore cetrificate you used for generating apk (debuge.keystore in case of development environment). Once you get the map api key for specific certificate you MUST use the same certificate debuge.keystore) to ganerate the apk file to run the app successfully on all the device otherwise it will shows blank map with grey square..

    • If you and your friend is generating apk from different machine/pc than you must use same debug certificate to generate the apk file