【问题标题】:android project in ... 'app' a resolved Google Play services library dependency depends on another at an exact version... 'app' 中的 android 项目已解决的 Google Play 服务库依赖项依赖于另一个确切版本
【发布时间】:2020-04-17 23:34:34
【问题描述】:

我有一个运行良好的应用程序,但今天它在构建项目时出错。 我花了一整天的时间从堆栈中尝试了太多的解决方案。什么都没有。

我有以下应用 -> build.gradle

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.myapp.immuno"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "2.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            aaptOptions.cruncherEnabled = false // here
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.navigation:navigation-fragment:2.1.0'
    implementation 'androidx.navigation:navigation-ui:2.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'com.google.code.gson:gson:2.8.5'

    // Firebase libraries
    implementation 'com.google.firebase:firebase-core:17.2.1'
    implementation 'com.google.firebase:firebase-messaging:20.1.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.1'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
    implementation 'com.google.firebase:firebase-auth:19.2.0'
    implementation 'com.google.firebase:firebase-crash:16.2.1'
    implementation 'com.google.firebase:firebase-database:19.2.0'
    implementation 'com.google.firebase:firebase-storage:19.1.0'

    // circular image
    implementation 'de.hdodenhof:circleimageview:2.2.0'

    // RecyclerView
    //noinspection GradleCompatible
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    //FacebookSdk
    //implementation 'com.facebook.android:facebook-android-sdk:4.37.0'
    //implementation 'com.facebook.android:facebook-login:4.37.0'

    // volley library
    implementation 'com.android.volley:volley:1.1.1'

    implementation 'com.google.android.gms:play-services:17.0.0'
    implementation 'me.dm7.barcodescanner:zxing:1.9.8'

    // Glide library to load images smoothly
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'

    // To get date and time
    implementation 'net.danlew:android.joda:2.10.1.1'

    // external libraries for mail
    implementation files('libs/activation.jar')
    implementation files('libs/additionnal.jar')
    implementation files('libs/mail.jar')

    // Add the Fabric Crashlytics plugin.
    //classpath 'io.fabric.tools:gradle:1.31.2'
    // Add the Firebase Crashlytics dependency.
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'


    }

    apply plugin: 'com.google.gms.google-services'
`

而 build.gradle 是

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'io.fabric.tools:gradle:1.31.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

在构建项目时出现此错误

错误:在项目“应用程序”中,已解析的 Google Play 服务库依赖项依赖于另一个确切版本(例如“[20.0.2]”,但未解析为该版本。库表现出的行为将不为人知。

依赖失败:com.google.firebase:firebase-messaging:20.1.0 -> com.google.firebase:firebase-iid@[20.0.2],但 firebase-iid 版本为 19.0.0。

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-iid@{strictly 19.0.0}
-- Project 'app' depends onto com.google.firebase:firebase-core@17.2.1
-- Project 'app' depends onto com.google.firebase:firebase-crash@16.2.1
-- Project 'app' depends onto com.google.firebase:firebase-messaging@{strictly 20.1.0}
-- Project 'app' depends onto com.google.firebase:firebase-messaging@20.1.0
-- Project 'app' depends onto com.google.firebase:firebase-crash@{strictly 16.2.1}
-- Project 'app' depends onto com.google.firebase:firebase-analytics@17.2.1
-- Project 'app' depends onto com.google.firebase:firebase-core@{strictly 17.2.1}
-- Project 'app' depends onto com.google.firebase:firebase-analytics@{strictly 17.2.1}
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-api@{strictly 17.2.1}

对于扩展调试信息,使用 ./gradlew --info :app:assembleDebug 从命令行执行 Gradle 以查看工件的依赖路径。此错误消息来自 google-services Gradle 插件,在 https://github.com/google/play-services-plugins 报告问题并通过将“googleServices { disableVersionCheck = false }”添加到您的 build.gradle 文件来禁用。

【问题讨论】:

  • 可能这个话题对你有帮助:stackoverflow.com/questions/54055141/…
  • @javaddroid 我尝试了该解决方案。我没有工作。
  • 尝试将所有库更新到最新的稳定版本。并再次测试。
  • 今天发生在我身上,没有改变任何依赖关系

标签: android firebase gradle


【解决方案1】:

这是我执行的步骤并解决了问题:

  1. 我把com.google.firebase:firebase-messaging:20.1.0改成了com.google.firebase:firebase-messaging:20.0.1
  2. 同步分级
  3. 并回滚更改(将 20.0.1 更改为 20.1.0
  4. 如果同步并运行应用程序,您将看到该问题已解决!

我知道这不是正确的方法,但解决了我的问题。任何正确的都应该被替换。

【讨论】:

  • 谢谢...我之前尝试过..它很奇怪,但它有效。你知道原因吗。为什么会这样。
  • 可能是因为缓存什么的。我真的不知道:/
【解决方案2】:

尝试以下两个步骤,可以解决很多此类问题 -

  1. 构建 -> 清理项目
  2. File -> Invalid Caches/Restart 在菜单中你可以只是无效的缓存或无效并重新启动(我更喜欢)

干杯...

【讨论】:

    【解决方案3】:

    对我来说,旧的重新启动计算机技巧就是这样做的,因为在重新启动 Android Studio 并清除缓存后我遇到了同样的问题。

    【讨论】:

      【解决方案4】:

      只需将库版本更新为

       implementation 'com.google.firebase:firebase-messaging:20.2.0'
      

      最后同步应用,你会看到问题解决了!

      【讨论】:

        猜你喜欢
        • 2019-05-31
        • 2019-07-03
        • 2020-08-24
        • 2023-04-02
        • 1970-01-01
        • 1970-01-01
        • 2019-09-09
        • 2019-07-16
        • 1970-01-01
        相关资源
        最近更新 更多