Como posso corrigir esse erro:
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: br.com.cadastroDeAluno, PID: 15217
java.lang.SecurityException: Client must have ACCESS_FINE_LOCATION permission to request PRIORITY_HIGH_ACCURACY locations.
at android.os.Parcel.readException(Parcel.java:1599)
at android.os.Parcel.readException(Parcel.java:1552)
at com.google.android.gms.location.internal.zzi$zza$zza.zza(Unknown Source)
at com.google.android.gms.location.internal.zzk.zza(Unknown Source)
at com.google.android.gms.location.internal.zzl.zza(Unknown Source)
at com.google.android.gms.location.internal.zzd$1.zza(Unknown Source)
at com.google.android.gms.location.internal.zzd$1.zza(Unknown Source)
at com.google.android.gms.internal.zzpr$zza.zzb(Unknown Source)
at com.google.android.gms.internal.zzqa.zzf(Unknown Source)
at com.google.android.gms.internal.zzqa.zzd(Unknown Source)
at com.google.android.gms.internal.zzqf.zzd(Unknown Source)
at com.google.android.gms.internal.zzqd.zzd(Unknown Source)
at com.google.android.gms.location.internal.zzd.requestLocationUpdates(Unknown Source)
at br.com.cadastroDeAluno.mapa.Localizador.onConnected(Localizador.java:43)
at com.google.android.gms.common.internal.zzl.zzo(Unknown Source)
at com.google.android.gms.internal.zzqd.zzm(Unknown Source)
at com.google.android.gms.internal.zzqb.zzapm(Unknown Source)
at com.google.android.gms.internal.zzqb.onConnected(Unknown Source)
at com.google.android.gms.internal.zzqf.onConnected(Unknown Source)
at com.google.android.gms.internal.zzpu.onConnected(Unknown Source)
at com.google.android.gms.common.internal.zzk$1.onConnected(Unknown Source)
at com.google.android.gms.common.internal.zzd$zzj.zzarz(Unknown Source)
at com.google.android.gms.common.internal.zzd$zza.zzc(Unknown Source)
at com.google.android.gms.common.internal.zzd$zza.zzx(Unknown Source)
at com.google.android.gms.common.internal.zzd$zze.zzasb(Unknown Source)
at com.google.android.gms.common.internal.zzd$zzd.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
D/NativeCrypto: ssl=0x7f71121b00 sslRead buf=0x7f8815e000 len=2048,timeo=2500
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:2
I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 2
D/GoogleCertificates: com.google.android.gms.googlecertificates module is loaded
D/GoogleCertificatesImpl: Fetched 190 Google release certificates
D/GoogleCertificatesImpl: Fetched 363 Google certificates
Classe:
package br.com.cadastroDeAluno.mapa;
import android.content.Context;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.Nullable;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.model.LatLng;
/**
* Created by Leandro on 18/10/2016.
*/
//classe responsável por gerenciar a parte do GPS
//classe Localizador que centraliza o mapa de acordo com a posição do dispositivo utilizando o GPS.
public class Localizador implements GoogleApiClient.ConnectionCallbacks, com.google.android.gms.location.LocationListener { //LocationListener
private final GoogleApiClient client; //a classe GoogleApiClient serve para fazer a conexão dentro do celular
private final MapaFragment mapaFragment;
public Localizador (Context context, MapaFragment mapaFragment){
client = new GoogleApiClient.Builder(context)
.addApi(LocationServices.API) //acessar o LocationsService
.addConnectionCallbacks(this)
.build();
client.connect();
this.mapaFragment = mapaFragment;
}
// metodo em que especificamos o que fazer ao conectar
@Override
public void onConnected(@Nullable Bundle bundle) {
LocationRequest request = new LocationRequest();
request.setSmallestDisplacement(50); //define o deslocamento minimo
request.setInterval(1000); //intervalo de envio da posição
request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); //com isso teremos uma precisão muito alta
LocationServices.FusedLocationApi.requestLocationUpdates(client, request, this);
}
//metodo em que especificamos o que fazer quando a conexao for suspensa
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onLocationChanged(Location location) {
LatLng coordenada = new LatLng(location.getLatitude(), location.getLongitude());
mapaFragment.centralizarEm(coordenada);
}
}