Meu código não compila e da o seguinte erro:
error: cannot access zzbej
class file for com.google.android.gms.internal.zzbej not found
Vi possíveis soluções aqui no Alura de pessoas que tiveram o mesmo problema que eu, mas não resolveu. Que foi fazer importação da dependência play-services-location (parece que não existe), aparece só do com.github.
Aqui vai meu código:
Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.claudiogaalvao.agenda"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.github.niqo01.rxplayservices:rx-play-services-location:0.4.0'
}
Localizador:
package com.claudiogaalvao.agenda;
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.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.LatLng;
public class Localizador implements GoogleApiClient.ConnectionCallbacks, LocationListener {
private final GoogleApiClient client;
private GoogleMap mapa;
public Localizador(Context context, GoogleMap mapa) {
client = new GoogleApiClient.Builder(context)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.build();
client.connect();
this.mapa = mapa;
}
@Override
public void onConnected(@Nullable Bundle bundle) {
LocationRequest request = new LocationRequest();
request.setSmallestDisplacement(50);
request.setInterval(1000);
request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
LocationServices.FusedLocationApi.requestLocationUpdates(client, request, this);
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onLocationChanged(Location location) {
LatLng coordenada = new LatLng(location.getLatitude(), location.getLongitude());
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLng(coordenada);
mapa.moveCamera(cameraUpdate);
}
}