我正在尝试将 Mapbox 与 google play 服务位置一起使用。
一切正常,直到我添加 implementation 'com.google.android.gms:play-services-location:16.0.0'
以便能够在应用程序处于后台时请求位置更新。
Gradle 构建良好,但在编译项目时出现以下错误:
....
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: com.mapbox.android.core.location.GoogleLocationEngine$1$2
at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:116)
at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:74)
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:59)
... 57 more
我之前遇到过类似的问题,我能够排除导致该问题的库。但是,使用 Mapbox 我不知道如何解决这个冲突。
我尝试过的:
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:6.8.0'){
exclude group: "com.google.android.gms", module: "play-services-location"
} // Probably will have no effect as this module doesn't seem to be a dependency of Mapbox
或
implementation ('com.google.android.gms:play-services-location:16.0.0'){
force = true
}
如有任何帮助,我们将不胜感激。
编辑:尝试 Mapbox 的 7.0.0 beta2 版本似乎可以解决问题,但我想避免在产品中使用 beta 版本,所以如果有任何方法我可以使用 google play services location
制作当前版本的 Mapbox会很棒
最佳答案
添加android位置服务:
implementation 'com.google.android.gms:play-services-location:16.0.0'
在 dependencies close 部分之后的 build.gradle(app level) 末尾添加这一行:
apply plugin: 'com.google.gms.google-services'
像这样:
dependencies {
...
implementation 'com.google.android.gms:play-services-location:16.0.0'
}
apply plugin: 'com.google.gms.google-services'
关于android - 程序类型已经存在 : com. mapbox.android.core.location.GoogleLocationEngine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53976080/