关于小狐狸版本的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' }
    }
}

你可能感兴趣的:(关于小狐狸版本的AS,编译报错 repository 'Google' was added by build file 'build.gradle问题完美解决)