简体   繁体   中英

LocationRequest and LocationServices.API are not resolved

I have a high priority project under development.
I am trying to insert geo location into db so I found a service online and unfortunately LocationRequest and LocationServices.API are not resolved.
I am using the dependency 'com.google.android.gms:play-services-maps:10.2.0'

在此输入图像描述

I tried adding the imports

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;

You can find the code I used at this link

Seems like you need to compile the play-services-location package.

Put these into the build.gradle

ext {
    playServicesVersion = '10.2.0' // update accordingly 
}

dependencies {
    ...
    compile "com.google.android.gms:play-services-maps:${playServicesVersion}"
    compile "com.google.android.gms:play-services-location:${playServicesVersion}"
}

在app.gradle中尝试此implementation 'com.google.android.gms:play-services-location:15.0.1' ,并定期更新版本。

试试这个implementation 'com.google.android.gms:play-services:12.0.1'为我工作

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM