Map does not appear in app

1

I'm adding a function in a my app that will show specific places near the user.

( Here is the example that I embedded )

Follow screen print in activity:

EDIT:

E/GoogleMapsAndroidAPI(21658):Authorizationfailure.PleaseseetheGoogleConsoleforhowtocorrectlysetupthemap.E/GoogleMapsAndroidAPI(21658):IntheGoogleDeveloperConsoleE/GoogleMapsAndroidAPI(21658):Ensurethatthe"Google Maps Android API v2" is enabled.
E/Google Maps Android API(21658): Ensure that the following Android Key exists:
E/Google Maps Android API(21658):   API Key: AIzaSyA********************************
E/Google Maps Android API(21658):   Android Application (<cert_fingerprint>;<package_name>): 42:89:CD:56:4E:08:9A:67:**:**:**:**:**:**:**:**:**:**:**:**;"NOME DO MEU PACOTE"

The key is created, but the above error occurs

A NullPointer also occurs:

java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference

I did not even change anything in the class.

The section where the error occurs:

Line 72:

StringBuilder sbValue = new StringBuilder(sbMethod());

Line 144:

    public StringBuilder sbMethod() throws SecurityException {
    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    String provider = locationManager.getBestProvider(criteria, true);
    Location myLocation = locationManager.getLastKnownLocation(provider);
    mLatitude = myLocation.getLatitude();
    mLongitude = myLocation.getLongitude();
    
asked by anonymous 19.12.2016 / 21:08

2 answers

0

Generate an api key:

link

At the moment you are getting the coordinate get, you may not have any cached

    
11.01.2017 / 13:40
0

Hello, I know this question is old, but I will share the solution of my experience with you, since it can help other people.

Recently I switched to OS and the same problem occurred with me, the solution was to install the latest version of Java through the link " link " and configure JAVAC accordingly " Javac is not recognized as internal or external command .

Thank you!

    
03.12.2017 / 18:28