Home>

Debugging a map app (using google map)

Current status

・ Build completed successfully
・ Check on emulator

Error

The following error occurs when debugging the actual machine (confirmed with Vaio Phone A)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.regu1.maptest1, PID: 15058
java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
at com.google.maps.api.android.lib6.impl.bg.c (: com.google.android.gms.dynamite_mapsdynamite @ 19056047 @ 19.0.56 (040308-262933554): 508)
at com.google.android.gms.maps.internal.m.a (: com.google.android.gms.dynamite_mapsdynamite @ 19056047 @ 19.0.56 (040308-262933554): 361)
at cv.onTransact (: com.google.android.gms.dynamite_mapsdynamite @ 19056047 @ 19.0.56 (040308-262933554): 4)
at android.os.Binder.transact (Binder.java:387)
at com.google.android.gms.internal.maps.zza.zzb (Unknown Source)
at com.google.android.gms.maps.internal.zzg.setMyLocationEnabled (Unknown Source)
at com.google.android.gms.maps.GoogleMap.setMyLocationEnabled (Unknown Source)
at com.regu1.maptest1.MapsActivity.onMapReady (MapsActivity.java:46)
at com.google.android.gms.maps.zzak.zza (Unknown Source)
at com.google.android.gms.maps.internal.zzaq.dispatchTransaction (Unknown Source)
at com.google.android.gms.internal.maps.zzb.onTransact (Unknown Source)
at android.os.Binder.transact (Binder.java:387)
at cw.b (: com.google.android.gms.dynamite_mapsdynamite @ 19056047 @ 19.0.56 (040308-262933554): 14)
at com.google.android.gms.maps.internal.be.a (: com.google.android.gms.dynamite_mapsdynamite @ 19056047 @ 19.0.56 (040308-262933554): 4)
at com.google.maps.api.android.lib6.impl.bj.run (: com.google.android.gms.dynamite_mapsdynamite @ 19056047 @ 19.0.56 (040308-262933554): 4)
at android.os.Handler.handleCallback (Handler.java:739)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:148)
at android.app.ActivityThread.main (ActivityThread.java:5417)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run (ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:616)
W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates: 0 and remote module com.google.android.gms.googlecertificates: 4
Selected remote version of com.google.android.gms.googlecertificates, version>= 4
W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/00000038/n/armeabi-v7a
ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/00000038/n/armeabi

package com.regu1.maptest1;
import androidx.fragment.app.FragmentActivity;
import android.os.Bundle;
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;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
    private GoogleMap mMap;
    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate (savedInstanceState);
        setContentView (R.layout.activity_maps);// Obtain the SupportMapFragment and get notified when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager ()
                .findFragmentById (R.id.map);
        mapFragment.getMapAsync (this);
    }

    / **
     * Manipulates the map once available.
     * This callback is triggered when the map is ready to be used.
     * This is where we can add markers or lines, add listeners or move the camera.In this case,
     * we just add a marker near Sydney, Australia.
     * If Google Play services is not installed on the device, the user will be prompted to install
     * it inside the SupportMapFragment.This method will only be triggered once the user has
     * installed Google Play services and returned to the app.
     * /
    @Override
    public void onMapReady (GoogleMap googleMap) {
        mMap = googleMap;
        // Add a marker in Sydney and move the camera
        LatLng sydney = new LatLng (-34, 151);
        mMap.addMarker (new MarkerOptions (). position (sydney) .title ("Marker in Sydney"));
        mMap.moveCamera (CameraUpdateFactory.newLatLng (sydney));
        mMap.setMyLocationEnabled (true);
    }
}
  • Answer # 1

    I think it is the same as below.

    FATAL EXCEPTION Android 6 and later maps fall

    From


    Is added to AndroidManifest.xml.
    [Android] Get location information using FusedLocationProviderClient

    The following pages will be helpful when obtaining permissions.
    A little kind of Runtime Permission support
    Referring to the above


    I think it would be good to get permission for these two.