0
I’m using this code:
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
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 static com.marcadorfixo.R.id.map;
public class MainActivity extends AppCompatActivity implements OnMapReadyCallback {
GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(map);
mapFragment.getMapAsync(MainActivity.this);
googleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng position) {
googleMap.addMarker(
new MarkerOptions().position(position)
);
}
});
}
@Override
public void onMapReady(GoogleMap googleMap) {
LatLng uaua = new LatLng(-9.840318, -39.480388);
googleMap.addMarker(new MarkerOptions()
.position(uaua)
.title("Uauá"));
}
}
Android Studio even compiles, but when trying to run the application it simply stops working.
What error presented by android studio?
– Antonio S. Junior
Dude, he doesn’t accuse error, that’s what I don’t understand. For example: He compiles, no error, then when I run the app it stops working. Like, if he did, and when he clicked on the map, he would stop and I could look for the problem myself, but not even that... I’ve looked for some tutorials, but it’s scarce.
– Higor Cardoso