Skip to content Skip to sidebar Skip to footer

Application Crashes When Using Google Maps V2 On Most Devices

Im trying to code some application that uses Google Maps API. The map is shown in the main activity. On some phones, including the emulator, the application crashes immediately aft

Solution 1:

Just do the following to check if google play services are available:

int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
    if(status == ConnectionResult.SUCCESS) {
        //Success! Do what you want

    }else{
        GooglePlayServicesUtil.getErrorDialog(status, this, status);
    }

It will check for google play services and if are not available it will prompt user to download them from google play

Solution 2:

It sounds as though the phones you're testing on don't have the latest Google Play Services pre-req's installed.

If you take a look here you'll find a section discussing how you can ensure that devices have the google play service APK installed and if not, direct the user to install it.

Also note that the emulator isn't supported on emulators running an API platform less than Andorid 4.2.2 (referenced here in the first section)

Solution 3:

I have the same exception on my app:

java.lang.NullPointerException: IBitmapDescriptorFactory isnot initialized

In my case, I have to call BitmapDescriptorFactory static method after initializing the Google Map object.

Read the comments:

// This line initilizes the map asynchronously. It requires implementation// of OnMapReadyCallback interface.// And when it is inizilized, it calls onMapReady(GoogleMap googleMap)
mapFragment.getMapAsync(this);


// The following method is implemented in my activity@OverridepublicvoidonMapReady(GoogleMap googleMap) {
    ... some code ...
    currentLocationIcon = BitmapDescriptorFactory.fromResource(R.drawable.report_location_current)
    ... some code ...
}

Solution 4:

GoogleApiAvailability googleApiAvailability=GoogleApiAvailability.getInstance();

int status=googleApiAvailability.isGooglePlayServicesAvailable(getActivity());

        if (status != ConnectionResult.SUCCESS) {
            intrequestCode=10;
            Dialogdialog= googleApiAvailability.getErrorDialog(getActivity(),status,requestCode);
            dialog.show();
        }else{}

Solution 5:

Refer here to check for Google Play Services available on your phone. If you encounter an error then it will display an error dialog returned from Google Play Services. I have worked on my application with Google Maps v2 on Samsung Galaxy S3 and its working fine.

Post a Comment for "Application Crashes When Using Google Maps V2 On Most Devices"