【问题标题】:How to solve error Dependency failing adding Firebase library如何解决错误依赖无法添加 Firebase 库
【发布时间】: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'

如何解决这个问题?我试图找到同样的问题,但没有解决我的问题。

【问题讨论】:

    标签: android firebase gradle


    【解决方案1】:

    签入您的 Android SDK 管理器。

    是否已安装?

    如果不是,则安装它。

    并添加这一行:

    implementation'com.google.firebase:firebase-auth:18.1.0'
    

    希望对你有所帮助。

    【讨论】:

    • 你能解释一下为什么他在配置sdk的时候需要实现auth吗?
    • 已安装。我还不需要身份验证。我只是尝试将 firebase 库添加到项目中
    【解决方案2】:

    我通过简单地删除以下几行来解决这个问题:

    implementation 'com.google.android.gms:play-services-measurement:17.0.1'
    implementation 'com.google.android.gms:play-services-measurement-sdk:17.0.1'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-07
      • 1970-01-01
      • 1970-01-01
      • 2015-04-25
      • 2023-02-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多