【发布时间】:2019-11-01 16:49:25
【问题描述】:
最近遇到一个问题,添加地理围栏会随机失败并出现 ApiException,状态代码 13 被定义为“错误”,没有提供额外的详细信息。
通常错误代码特定于地理围栏,但这似乎是一般故障。有谁知道为什么 GeofencingClient 会返回状态码 13?我一直找不到遇到同样问题的人。
这似乎影响了以前正常运行的应用程序的旧版本。
我已经仔细检查了纬度/经度是否为有效坐标,相同的数据有时也可以正常工作。我尝试使用不同的 API 密钥进行初始化,以防地图/位置服务出现问题,但这并没有什么不同。
我也尝试过从
GeofencingClient(context) 到 LocationServices.getGeofencingClient(context) 没有变化。
我已经尝试升级库版本,没有区别。
定义了播放服务版本和 API 密钥的典型清单设置;
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/maps_api_key"/>
<service android:name=".GeofenceTransitionsIntentService"/>
地理围栏被添加到这里,并且没有任何结果到达意图服务
private val geofencingClient = GeofencingClient(context)
private val geofencePendingIntent =
PendingIntent.getService(context, 0, Intent(context, GeofenceTransitionsIntentService::class.java), PendingIntent.FLAG_UPDATE_CURRENT)
fun setGeofence(latitude: Double, longitude: Double, radius: Float, geofenceId: String) {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
val geofenceList = listOf(buildGeofence(latitude, longitude, radius, geofenceId))
geofencingClient.addGeofences(getGeofencingRequest(geofenceList), geofencePendingIntent)?.run {
addOnFailureListener {
// Failed to add geofences
geofenceErrorListener?.invoke("Failed to add Geofence: ${it.message}")
}
}
}
}
这直到最近才成为问题,现在几乎 100% 的时间都在发生。
com.google.android.gms.common.api.ApiException: 13:
编辑:从 PlayServices 版本 17.7.85(在我的设备上)开始,该问题似乎已在 Google 端得到解决
【问题讨论】:
-
我这几天也有同样的问题
-
我也遇到了这种情况,希望有人能提供解决方案:-)
-
+1,刚开始突然看到这个,没有发布任何更新。 Google 端或最新版本的 Google Play 服务一定有问题。希望它很快得到解决 - 我不确定我们是否能做些什么。
-
是的,我想我已经追踪到 6 月 11 日对 Google Play 服务版本 17.x 的更新。在尚未更新的旧版本 16.x 上不会出现此问题。将通过电子邮件向 Play 服务团队发送电子邮件
-
@Ldawg - 你还在遇到这个问题吗?我不再有这个问题了,但我不确定我是否只是走运。我的 Google Play 服务没有更新或任何东西。谢谢!
标签: android google-play-services android-pendingintent android-geofence