Google Maps Android SDK: onMapReady() is called but map tiles never render (marker visible, API key configured)


I'm facing a strange issue with the Google Maps SDK in my Android app.

Problem

onMapReady() is called successfully.

I receive a valid GoogleMap object.

I can add markers.

No crashes occur.

However, the map tiles never render. The map remains blank/gray.

✅ Internet permission is added.

Google Maps API key is present in the manifest.

Maps SDK for Android is enabled in Google Cloud Console.

✅ Billing is enabled.

✅ SHA-1 fingerprint is added.

✅ Package name matches the application ID.

✅ Generated a new API key and tested with it.

✅ Removed Android application restrictions (tested with unrestricted API key).

✅ Tested both debug and release SHA-1.

✅ Google Maps works correctly in a brand-new sample project using the same API key.

package com.zms.agent;

import static androidx.core.view.WindowCompat.enableEdgeToEdge;

import android.Manifest;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.libraries.places.api.Places;

public class MapTestAct extends AppCompatActivity implements OnMapReadyCallback {
    GoogleMap googleMap;

    private static final String TAG = "MAP_TEST";
    private static final int LOCATION_PERMISSION_REQUEST = 100;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);

        if (!Places.isInitialized()) {
            Places.initialize(this, "");
        }

        try {
            ApplicationInfo ai = getPackageManager().getApplicationInfo(
                    getPackageName(),
                    PackageManager.GET_META_DATA
            );
            Bundle bundle = ai.metaData;
            Log.d("MAP_KEY", bundle.getString("com.google.android.geo.API_KEY"));
        } catch (Exception e) {
            e.printStackTrace();
        }


        int status = GoogleApiAvailability.getInstance()
                .isGooglePlayServicesAvailable(this);

        Log.d("MAP_TEST", "Play Services Status = " + status);

        Log.d("MAP_TEST", "onCreate");

        SupportMapFragment mapFragment =
                (SupportMapFragment) getSupportFragmentManager()
                        .findFragmentById(R.id.map);

        Log.d("MAP_TEST", "Fragment = " + mapFragment);

        if (mapFragment != null) {
            mapFragment.getMapAsync(this);
        }else {

            Log.e(TAG, "Map Fragment is NULL");

        }
    }

    @Override
    public void onMapReady(@NonNull GoogleMap map) {

        Log.d(TAG, "Google Play Services Version = " +
                GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE);

        Log.d("MAP_TEST", "Map is ready");

        googleMap=map;

        googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
            @Override
            public void onMapLoaded() {
                Log.d("MAP_TEST", "Map tiles loaded completely!");
            }
        });


        googleMap.setOnMapClickListener(latLng ->
                Log.d(TAG, "Map clicked"));

        LatLng mumbai = new LatLng(19.0760, 72.8777);

        googleMap.addMarker(new MarkerOptions().position(mumbai).title("Mumbai"));
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mumbai, 15f));

        Log.d("MAP_TEST", "Camera moved");
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.d(TAG,"onStart");
    }


    @Override
    protected void onResume() {
        super.onResume();
        Log.d(TAG,"onResume");
    }


    @Override
    protected void onPause() {
        super.onPause();
        Log.d(TAG,"onPause");
    }


    @Override
    protected void onStop() {
        super.onStop();
        Log.d(TAG,"onStop");
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d(TAG,"onDestroy");
    }


    @Override
    public void onLowMemory() {
        super.onLowMemory();

        Log.d(TAG,"onLowMemory");
    }

    private  void checkLocation(){


    }

}

1
Jul 20 at 7:49 AM
User Avatarpriya koli
#java#android#kotlin

No answer found for this question yet.