0

Iam practicing on Google Maps for android development. I have followed the steps as in https://developers.google.com/maps/documentation/android-api/map-with-marker While when playing the app I got the screen like this below, no marker and the map cannot show any thingenter image description here

My code as following:

public class MainActivity extends AppCompatActivity implements OnMapReadyCallback {

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

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

@Override
public void onMapReady(GoogleMap googleMap) {
    // Add a marker in Sydney, Australia,
    // and move the map's camera to the same location.
    LatLng sydney = new LatLng(-33.852, 151.211);
    googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));

}

}

******** . XML Layout ************

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.ae.map_04.MainActivity">

<fragment
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:id="@+id/map"
   android:name="com.google.android.gms.maps.SupportMapFragment" />


</LinearLayout>
Ahmed
  • 93
  • 7

1 Answers1

0

This is most likely an API Key issue. You can find some guidance here: Android Studio - Google map still blank on real Android device on release apk

If that does not work, try a new API Key.