Map does not appear in application

Asked

Viewed 1,060 times

1

I’m adding a feature in an app of mine that will show specific locations near the user.

( Follow the example that struck me )

Follow screen print on Activity:

Tela

EDIT:

E/Google Maps Android API(21658): Authorization failure.  Please see the Google Console for how to correctly set up the map.
E/Google Maps Android API(21658): In the Google Developer Console
E/Google Maps Android API(21658): Ensure that the "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

Also occurs a Nullpointer:

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

I didn’t even change anything in class.

Follow 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();
  • Detail more your problem, put parts of your code.

  • 1

    You generated the API key?

  • Gerei, @Thiagoluizdomacoski

  • Displays an error in the Console?

  • I added console errors here, @Thiagoluizdomacoski

  • Put it on, @Taisbevalle

  • debug or release mode?

  • has a part that says "Ensure that the "Google Maps Android API v2" is enabled.". Vc saw if in the google dashboard vc enabled the maps?

  • @Andrévicente there on the console only found Google Maps Android API, not found Google Maps V2.

  • I decided! I changed the tag android:name="com.google.android.maps.V2.API_KEY" by android:name="com.google.android.geo.API_KEY".

Show 5 more comments

2 answers

0

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.