実現したいこと
地図アプリ(google mapを利用)の実機デバッグ
現状
・ビルドは正常に終了
・エミュレータ上で確認
エラー
実機(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
Java
1package com.regu1.maptest1; 2 3import androidx.fragment.app.FragmentActivity; 4 5import android.os.Bundle; 6 7import com.google.android.gms.maps.CameraUpdateFactory; 8import com.google.android.gms.maps.GoogleMap; 9import com.google.android.gms.maps.OnMapReadyCallback; 10import com.google.android.gms.maps.SupportMapFragment; 11import com.google.android.gms.maps.model.LatLng; 12import com.google.android.gms.maps.model.MarkerOptions; 13 14public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { 15 16 private GoogleMap mMap; 17 18 @Override 19 protected void onCreate(Bundle savedInstanceState) { 20 super.onCreate(savedInstanceState); 21 setContentView(R.layout.activity_maps); 22 // Obtain the SupportMapFragment and get notified when the map is ready to be used. 23 SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 24 .findFragmentById(R.id.map); 25 mapFragment.getMapAsync(this); 26 } 27 28 29 /** 30 * Manipulates the map once available. 31 * This callback is triggered when the map is ready to be used. 32 * This is where we can add markers or lines, add listeners or move the camera. In this case, 33 * we just add a marker near Sydney, Australia. 34 * If Google Play services is not installed on the device, the user will be prompted to install 35 * it inside the SupportMapFragment. This method will only be triggered once the user has 36 * installed Google Play services and returned to the app. 37 */ 38 @Override 39 public void onMapReady(GoogleMap googleMap) { 40 mMap = googleMap; 41 42 // Add a marker in Sydney and move the camera 43 LatLng sydney = new LatLng(-34, 151); 44 mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); 45 mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); 46 mMap.setMyLocationEnabled(true); 47 } 48}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/11/23 13:22
2019/11/23 14:25 編集
2019/11/27 05:44
2019/11/27 06:10