【发布时间】:2019-08-13 12:15:01
【问题描述】:
我尝试通过 firebase 设置说明将 Firebase 库添加到项目中,但出现错误。
ERROR: In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[17.0.
0]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: com.google.android.gms:play-services-measurement-api:17.0.0 -> com.google.android.gms:play-services-
measurement-impl@[17.0.0], but play-services-measurement-impl version was 17.0.1.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends onto com.google.firebase:firebase-core@17.0.1
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-sdk@17.0.1
-- Project 'app' depends onto com.google.firebase:firebase-analytics@{strictly 17.0.0}
-- Project 'app' depends onto com.google.android.gms:play-services-ads@{strictly 18.1.1}
-- Project 'app' depends onto com.google.android.gms:play-services-ads@18.1.1
-- Project 'app' depends onto com.google.android.gms:play-services-ads-lite@{strictly 18.1.1}
-- Project 'app' depends onto com.google.firebase:firebase-core@{strictly 17.0.1}
-- Project 'app' depends onto com.google.android.gms:play-services-measurement@17.0.1
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-impl@{strictly 17.0.1}
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-api@{strictly 17.0.0}
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-sdk@{strictly 17.0.1}
-- Project 'app' depends onto com.google.android.gms:play-services-measurement@{strictly 17.0.1}
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
uild.gradle file.
项目build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.google.gms:google-services:4.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用程序build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.project"
minSdkVersion 18
targetSdkVersion 28
versionCode 17
versionName "1.0.3"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'com.google.android.material:material:1.1.0-alpha09'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0-rc01'
implementation 'androidx.preference:preference:1.1.0-rc01'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.billingclient:billing:2.0.3'
implementation 'com.google.android.gms:play-services-ads:18.1.1'
implementation 'com.google.android.gms:play-services-measurement:17.0.1'
implementation 'com.google.android.gms:play-services-measurement-sdk:17.0.1'
implementation 'androidx.multidex:multidex:2.0.1'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-core:17.0.1'
}
apply plugin: 'com.google.gms.google-services'
如何解决这个问题?我试图找到同样的问题,但没有解决我的问题。
【问题讨论】: