Android Gradle库“无法解决" [英] Android gradle libraries 'failure to resolve'

查看:61
本文介绍了Android Gradle库“无法解决"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图哄骗许多android库一起很好地玩,但是我对版本控制系统感到沮丧.

I'm trying to coax a number of android libraries to play nicely together but I'm becoming frustrated with the versioning system.

我设法使firebase版本的crashlytics正常工作,但目前无法使其与admob一起正常工作.

I've managed to get the firebase version of crashlytics working but I cannot currently get this to work well with admob:

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

in my app 'build.gradle' I have the following dependency section:

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"产生此错误:

'16.0.4' also fails whereas '17.1.1' produces this error:

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"

thinking that maybe all of the dependencies need to be '17.1.1' results in gradle not finding 'com.google.firebase:firebase-core:17.1.1'

我怀疑我是否一个人发现这种汤有些不透明.有没有更简单的方法来确保一组库可以很好地协同工作?

I doubt I'm alone in finding this version soup somewhat opaque. Is there an easier way to ensure a set of libraries that work well together?

推荐答案

添加:

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

并在顶级gradle文件中使用最新版本的Google Play服务:

and in top level gradle file use the latest version of google play services:

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

注意:

您需要按照firebase文档中的指定,在顶级gradle文件中添加google()存储库,并且该文件也应位于jcenter()之前:

You need to add the google() repo in the top level gradle file, as specified in the firebase docs and also it should be before 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()
  }
}

这篇关于Android Gradle库“无法解决"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆