大家好,我正在开发简单的食品配送android应用程序,因此它需要集成谷歌地图和我遵循的自动建议以查找当前位置
[google sample code](https://github.com/googlemaps/android-samples/blob/master/tutorials/CurrentPlaceDetailsOnMap/app/src/main/java/com/example/currentplacedetailsonmap/MapsActivityCurrentPlace.java)
对于我遵循的自动建议
https://developers.google.com/places/android-sdk/autocomplete
构建时gradle显示重复的类错误
Duplicate class com.google.android.libraries.places.api.internal.impl.net.pablo.AutocompletePredictionResult found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.api.internal.impl.net.pablo.AutocompletePredictionResult$StructuredFormatting found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.api.internal.impl.net.pablo.AutocompletePredictionResult$Substring found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.api.internal.impl.net.pablo.FetchPlacePabloResponse found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.internal.bc found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.internal.bd found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
Duplicate class com.google.android.libraries.places.internal.be found in modules classes.jar (com.google.android.libraries.places:places-compat:1.1.0) and classes.jar (com.google.android.libraries.places:places:1.1.0)
这是我的礼物
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
implementation 'com.google.android.libraries.places:places:1.1.0'
我尝试通过以下方式排除重复的课程
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
implementation ('com.google.android.libraries.places:places:1.1.0'){
exclude group:'com.google.android.libraries.places.api.internal.impl.net.pablo'
exclude group: 'com.google.android.libraries.places.internal'
}
但是没有什么可以解决我的问题。
答案 0 :(得分:0)
删除
implementation'com.google.android.libraries.places:places-compat:1.1.0'
并仅保留implementation 'com.google.android.libraries.places:places:1.1.0'
。
使用
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
仅在使用已弃用的
库时才是必需的
implementation 'com.google.android.gms:play-services-places:16.0.0'
请看看here和documentation。