This is based off my last question as well.
这也是我最后一个问题的基础。
Following this tutorial, I cloned the project into my machine and am trying to get the project to build properly.
在本教程之后,我将项目克隆到我的机器中,并试图使项目正确地构建。
In the process of fixing the error I got in my last question, I encountered a new error.
This is the section of the build script I am trying to fix/edit
在修正最后一个问题的过程中,我遇到了一个新的错误。这是我正在尝试修复/编辑的构建脚本的一部分。
buildscript {
repositories {
mavenCentral()
mavenLocal()
maven { url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/' }
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.3'
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
Following the instructions on how to check Gradle version, I checked mine and saw that I was running Gradle version 2.2.1. Based off that, I changed
按照如何检查Gradle版本的说明,我查看了我的版本,并发现我正在运行Gradle版本2.2.1。基于此,我改变了。
classpath 'com.android.tools.build:gradle:1.2.3'
to
来
classpath 'com.android.tools.build:gradle:2.2.1'
However after changing that build script code, and attempting to rebuild my project, I get the above mentioned error(full stack trace below)
但是,在修改了构建脚本代码并尝试重新构建我的项目之后,我得到了上面提到的错误(下面的完整堆栈跟踪)
Error:Could not find com.android.tools.build:gradle:2.2.1.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
file:/C:/Users/chris/.m2/repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
file:/C:/Users/chris/.m2/repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
Required by:
:theplanethatcouldntflygood:unspecified
Does anyone know why I am getting this error or how to fix this? It doesn't make sense for me to point the Java compiler(classpath) at a Gradle Version that I am not even using.
有人知道我为什么会犯这个错误吗?对我来说,将Java编译器(类路径)放在一个我甚至不使用的Gradle版本中是没有意义的。
5 个解决方案
#1
26
You are confusing between android gradle plugin and gradle version.
你很容易混淆android gradle插件和gradle版本。
This classpath 'com.android.tools.build:gradle:1.2.3'
is a gradle plugin for Android and as of this time, 1.2.3 is the latest.
这个类路径'com.android.tools.build:gradle:1.2.3'是Android的一个gradle插件,在这个时候,1.2.3是最新的。
The gradle version itself is in gradle-wrapper.properties file. 2.4 is the latest version,
gradle版本本身是一个层次的包装。属性文件。2.4是最新版本,
#2
6
you can find last version in this address :
repo1.maven.org/maven2/com/android/tools/build/gradle
jcenter.bintray.com/com/android/tools/build/gradle
您可以在这个地址找到最后一个版本:repo1.maven.org/maven2/com/android/tools/build/gradle jcenter.bintray.com/com/android/tools/build/gradle。
buildscript {
repositories {
maven { url "https://jcenter.bintray.com" }
maven { url "http://repo1.maven.org/maven2" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
maven { url "https://jcenter.bintray.com" }
maven { url "http://repo1.maven.org/maven2" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
#3
6
Per @Hamidreza's answer, check the maven and jcenter repos. Indeed jcenter (currently) has newer tools than maven.
每个@Hamidreza的答案,检查maven和jcenter repos。的确,jcenter(目前)拥有比maven更新的工具。
So in the top-level build.gradle
file, change "mavenCentral" to "jcenter" like this
在顶层构建中。等级文件,将“mavenCentral”改为“jcenter”。
repositories {
//mavenCentral()
jcenter()
}
#4
0
I fixed this exact issue by upgrading my version of Android Studio. I was receiving an error Could not find com.android.tools.build:gradle:2.2.0
, and was running a 2.1.x version of Studio at the time.
通过升级我的Android Studio,我解决了这个问题。我收到了一个错误,无法找到com.android.tools.build:gradle:2.2.0,运行了2.1。x版本的工作室。
A simple upgrade to 2.2.2 immediately fixed my issue. Hope this can help somebody!
一个简单的升级到2.2.2立即解决了我的问题。希望这能帮助别人!
#5
0
If you're behind a proxy, make sure Android Studio is set up for that. It does NOT assume system proxy settings.
如果你在一个代理的后面,确保Android Studio是为它设置的。它不假定系统代理设置。
My copy of Studio + Gradle wasn't set up to go through the proxy, and as a result it was giving me this error. Would've been nice to get a clear "hey buddy, I can't hit the web", but I got this error instead.
我的Studio + Gradle的拷贝不是通过代理设置的,结果它给了我这个错误。很高兴能得到一个明确的“嘿,伙计,我不能打网络”,但我得到了这个错误。
#1
26
You are confusing between android gradle plugin and gradle version.
你很容易混淆android gradle插件和gradle版本。
This classpath 'com.android.tools.build:gradle:1.2.3'
is a gradle plugin for Android and as of this time, 1.2.3 is the latest.
这个类路径'com.android.tools.build:gradle:1.2.3'是Android的一个gradle插件,在这个时候,1.2.3是最新的。
The gradle version itself is in gradle-wrapper.properties file. 2.4 is the latest version,
gradle版本本身是一个层次的包装。属性文件。2.4是最新版本,
#2
6
you can find last version in this address :
repo1.maven.org/maven2/com/android/tools/build/gradle
jcenter.bintray.com/com/android/tools/build/gradle
您可以在这个地址找到最后一个版本:repo1.maven.org/maven2/com/android/tools/build/gradle jcenter.bintray.com/com/android/tools/build/gradle。
buildscript {
repositories {
maven { url "https://jcenter.bintray.com" }
maven { url "http://repo1.maven.org/maven2" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
maven { url "https://jcenter.bintray.com" }
maven { url "http://repo1.maven.org/maven2" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
#3
6
Per @Hamidreza's answer, check the maven and jcenter repos. Indeed jcenter (currently) has newer tools than maven.
每个@Hamidreza的答案,检查maven和jcenter repos。的确,jcenter(目前)拥有比maven更新的工具。
So in the top-level build.gradle
file, change "mavenCentral" to "jcenter" like this
在顶层构建中。等级文件,将“mavenCentral”改为“jcenter”。
repositories {
//mavenCentral()
jcenter()
}
#4
0
I fixed this exact issue by upgrading my version of Android Studio. I was receiving an error Could not find com.android.tools.build:gradle:2.2.0
, and was running a 2.1.x version of Studio at the time.
通过升级我的Android Studio,我解决了这个问题。我收到了一个错误,无法找到com.android.tools.build:gradle:2.2.0,运行了2.1。x版本的工作室。
A simple upgrade to 2.2.2 immediately fixed my issue. Hope this can help somebody!
一个简单的升级到2.2.2立即解决了我的问题。希望这能帮助别人!
#5
0
If you're behind a proxy, make sure Android Studio is set up for that. It does NOT assume system proxy settings.
如果你在一个代理的后面,确保Android Studio是为它设置的。它不假定系统代理设置。
My copy of Studio + Gradle wasn't set up to go through the proxy, and as a result it was giving me this error. Would've been nice to get a clear "hey buddy, I can't hit the web", but I got this error instead.
我的Studio + Gradle的拷贝不是通过代理设置的,结果它给了我这个错误。很高兴能得到一个明确的“嘿,伙计,我不能打网络”,但我得到了这个错误。