androidstudio maven仓库配置

来源:互联网 发布:有公积金借钱软件 编辑:程序博客网 时间:2024/06/04 00:53

前几天在家里安装androidstudio一直编译不了,对了网上的配置改了好久都不行,最后的配置OK。

参考http://blog.csdn.net/u010665691/article/details/44558937这边博客,发现maven.oschina.net根本访问不了,就默认修改为https://repo1.maven.org/maven2,其他不用改也成功了。

* What went wrong:A problem occurred configuring project ':app'.> Could not resolve all dependencies for configuration ':app:_debugAndroidTestApkCopy'.   > Could not resolve com.squareup:javawriter:2.1.1.     Required by:         project :app > com.android.support.test.espresso:espresso-core:2.2.2      > Could not resolve com.squareup:javawriter:2.1.1.         > Could not get resource 'http://maven.oschina.net/content/groups/public/com/squareup/javawriter/2.1.1/javawriter-2.1.1.pom'.            > Could not HEAD 'http://maven.oschina.net/content/groups/public/com/squareup/javawriter/2.1.1/javawriter-2.1.1.pom'.               > Connect to maven.oschina.net:80 [maven.oschina.net/183.78.182.122] failed: Connection timed out: connect   > Could not resolve javax.inject:javax.inject:1.     Required by:         project :app > com.android.support.test.espresso:espresso-core:2.2.2      > Could not resolve javax.inject:javax.inject:1.         > Could not get resource 'http://maven.oschina.net/content/groups/public/javax/inject/javax.inject/1/javax.inject-1.pom'.            > Could not HEAD 'http://maven.oschina.net/content/groups/public/javax/inject/javax.inject/1/javax.inject-1.pom'.               > Connect to maven.oschina.net:80 [maven.oschina.net/183.78.182.122] failed: Connection timed out: connect   > Could not resolve org.hamcrest:hamcrest-library:1.3.

如下:

1.修改C:\Users\Administrator\.gradle\init.gradle文件如下

allprojects{    repositories {        def REPOSITORY_URL = 'https://repo1.maven.org/maven2'        all { ArtifactRepository repo ->            if(repo instanceof MavenArtifactRepository){                def url = repo.url.toString()                if (url.startsWith('http://maven.oschina.net/content/groups/public') || url.startsWith('https://jcenter.bintray.com/')) {                    project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."                    remove repo                }            }        }        maven {            url REPOSITORY_URL        }    }}