当我尝试使用gradle包装器构建我的项目时,我收到此错误:
./gradlew
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all files for configuration ':app:classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
https://maven.fabric.io/public/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://maven.fabric.io/public/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
project :app
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
Run Code Online (Sandbox Code Playgroud)
同一个项目在Android Studio中构建正常.
我已经检查了这个和这个,但我使用gradle包装器版本4.1,添加了google()存储库,甚至尝试过设置android.enableAapt2=false.还有其他提示吗?谢谢.
我的根build.gradle文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
我的gradle-wrapper.properties档案:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Run Code Online (Sandbox Code Playgroud)
更新:加布里埃尔是对的.我还要在以下位置添加存储库app/build.gradle file:
...
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
...
Run Code Online (Sandbox Code Playgroud)
我想我很困惑这个stament "要添加这些图书馆之一到您的构建,包括顶层的build.gradle文件谷歌的Maven仓库"在这里.
小智 13
只是想留下额外的小费.当我安装Android Studio时,我在某处读到了建议保留此配置(带有'+'符号)
build.gradle(项目)
dependencies {
classpath 'com.android.tools.build:gradle:+'
.....
#more lines here
}
Run Code Online (Sandbox Code Playgroud)
但是,我使用的项目使用旧版本的gradle,此行始终请求最新版本.我花了一段时间来搞清楚.
| 归档时间: |
|
| 查看次数: |
15056 次 |
| 最近记录: |