從Github上拉了一個項目,沒法運行,按照正常邏輯
1、先更改 rootProject 下 build.gradle
文件中的
classpath 'com.android.tools.build:gradle:x.x.x' // 版本和你新建項目一致
2、在改 gradle-wrapper.properties
文件中的 distributionUrl
值 ,同樣與新建項目值對應
執行上面步驟後,按道理應該是可以了,但是還是報錯
A problem occurred configuring root project 'xxxxxxx'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.2.1.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.2.1.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
> Connect to repo.jfrog.org:443 [repo.jfrog.org/35.153.64.121, repo.jfrog.org/52.72.179.201] failed: Connection timed out: connect
估計是項目太老了
對比了一下新項目,在 rootProject 下 build.gradle
文件中的 更改如下
buildscript {
repositories {
jcenter()
mavenLocal() // 添加
google() // 添加
}
//......
}
}
allprojects {
repositories {
jcenter()
mavenLocal() // 添加
google() // 添加
}
}
在對應的位置添加代碼重新 rebulid 一下就可以了,如果遇到上面問題可以嘗試一下,不一定適用所有的項目,祝好!