关于小狐狸版本的AS,编译报错 repository ‘Google‘ was added by build file ‘build.gradle问题完美解决

错误关联:Failed to resolve: 、 repository ‘Google’ was added by build file 'build.gradle

首先我导入一个库后编译项目遇到这样的问题:

出现Failed to resolve: com.github.chrisbanes:PhotoView的问题,
你们的工程可能报各种库的问题,但开头都是Failed to resolve:com.github.xxxx.xxxx
则应在项目的 build.gradle 添加如下:

 maven {url"https://jitpack.io"} 

在小狐狸版本之前,只要我们在全局的build.gradle添加即可,例如:

allprojects {
	repositories {
		google()
		jcenter()
		maven {url"https://jitpack.io"} 
	}
}

注意,下载最新版本的AS,如果在项目的build.gradle中添加项目编译需要的依赖,
然后,报错,编译不过。

problem occurred evaluating root project 'My Application'.
Build was configured to prefer settings repositories over project repositories but repository 'Google' 
was added by build file 'build.gradle

注意: Google最新的项目编译依赖配置改到settings.gradle中了,解决如下:

In settings.gradle you can add the repositories you want to add to the project

dependencyResolutionManagement {
   repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
   repositories {
      google()
      mavenCentral()
      jcenter()
      maven { url 'https://jitpack.io' }
    }
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值