Android gradle 图书馆 'failure to resolve'

Android gradle libraries 'failure to resolve'

我正在尝试让许多 android 库一起很好地发挥作用,但我对版本控制系统感到很沮丧。

我已经设法让 crashlytics 的 firebase 版本正常工作,但我目前无法让它与 admob 一起正常工作:

在我的应用程序中 'build.gradle' 我有以下依赖项部分:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')    
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'    
    implementation 'com.crashlytics.sdk.android:crashlytics-ndk:2.0.5'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.6'
    implementation 'com.google.android.gms:play-services-ads:16.0.1'    
}

产生此错误的原因:

Failed to resolve: com.google.android.gms:play-services-ads:16.0.1

“16.0.4”也失败,而“17.1.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@16.0.1
-- Project 'app' depends onto com.google.android.gms:play-services-ads@17.1.1

认为可能所有依赖项都需要是“17.1.1”导致 gradle 找不到 'com.google.firebase:firebase-core:17.1.1'

我怀疑只有我一个人觉得这个版本汤有点不透明。有没有更简单的方法来确保一组库可以很好地协同工作?

请使用以下版本:

implementation 'com.google.android.gms:play-services-ads:17.1.1'

还将 firebase-core 库更新到版本 16.0.4:

implementation 'com.google.firebase:firebase-core:16.0.4'

添加:

 implementation 'com.google.firebase:firebase-core:16.0.4'
 implementation 'com.google.android.gms:play-services-ads:17.1.1'

并在顶级 gradle 文件中使用最新版本的 google 播放服务:

classpath 'com.google.gms:google-services:4.0.2'

注:

您需要在顶级 gradle 文件中添加 google() 存储库,如 firebase 文档中所指定,并且它应该在 jcenter():

之前
buildscript {
  repositories {
          google()
          jcenter()
      }


dependencies {
  classpath 'com.android.tools.build:gradle:3.2.1'
  classpath 'com.google.gms:google-services:4.0.2'
   }
}

allprojects {
     repositories {
              google()
             jcenter()
  }
}