我在编译代码时遇到此错误。我的项目build.gradle是:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.shubham.tommpas"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
//library required to display map
api 'com.tomtom.online:sdk-maps:2.+'
//library required for search
api 'com.tomtom.online:sdk-search:2.+'
//library required for routing
api 'com.tomtom.online:sdk-routing:2.+'
//library required for traffic
api 'com.tomtom.online:sdk-traffic:2.+'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.ankitdubey021:GPSTracker:2.0'
implementation "com.google.android.gms:play-services-maps:16.0.0"
implementation "com.google.android.gms:play-services-base:16.0.0"
implementation "com.google.android.gms:play-services-location:16.0.0"
implementation 'com.android.support:multidex:1.0.3'
}
问题是什么,我该如何解决?
答案 0 :(得分:-1)
在gradle中为存储库添加google()。如果它不像下面那样。如果已经存在,则应位于jcenter()之上。请在两个地方都将其向上移动。我也遇到了同样的问题,这就是我解决问题的方式。
buildscript {
repositories {
google()
jcenter()
}
......
....
allprojects {
repositories {
google()
jcenter()
}
}
通过从“ com.github.ankitdubey021:GPSTracker”依赖项中排除com.google.android.gms来进行尝试。因为它也使用此依赖关系,并且将可传递地添加到您的gradle中。这很可能是您遇到问题的原因。您可以通过更改“ com.github.ankitdubey021:GPSTracker”将其排除如下。
implementation('com.github.ankitdubey021:GPSTracker') {
exclude group: 'com.google.android.gms', module: 'play-services'
}