【发布时间】:2019-01-14 07:22:10
【问题描述】:
我是 android 编程的新手。我正在尝试访问某个位置,但此代码有错误。
getFusedLocationProviderClient(this).requestLocationUpdates(mLocationRequest, new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
// do work here
onLocationChanged(locationResult.getLastLocation());
}
},
Looper.myLooper());
我已将dependencies 包含在我的应用程序build.gradle 中
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services:12.0.1'
我应该导入或包含什么才能使此方法符号起作用? 请帮忙
【问题讨论】:
-
你用的是什么版本的gradle?如果是旧版本,则需要将
implementation更改为compile -
@HedeH gradle 版本 4.4
-
如果你没有静态导入然后:
getFusedLocationProviderClient(this)>>>LocationServices.getFusedLocationProviderClient(getContext()) -
确保您已将类路径添加到根项目
dependencies { classpath 'com.google.gms:google-services:4.0.1' // google-services plugin },并且不要忘记清理和构建。
标签: android google-maps-android-api-2 android-gps