Java 将 Android Studio Gradle 插件更新到最新版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29702491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Update Android Studio Gradle plugin to last version
提问by Jidey
I'm new to Android developpement and I tried to install the Facebook SDK in my Android Studio project.
我是 Android 开发新手,我尝试在我的 Android Studio 项目中安装 Facebook SDK。
Then, I have a bug in build.gradle :
然后,我在 build.gradle 中有一个错误:
Error:(111, 0) Cannot call getBootClasspath() before setTargetInfo() is called.
So I searched for a solution and I found this on the stack:
所以我搜索了一个解决方案,我在堆栈中找到了这个:
This is a known issue , which is fixed by updating gradle to :
这是一个已知问题,可通过将 gradle 更新为:
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
}
So I tried this but then I got the error:
所以我尝试了这个,但后来我得到了错误:
Error:Could not find com.android.tools.build:gradle:1.1.2.
Searched in the following locations:
file:/home/roman/Documents/softs/android-studio/gradle/m2repository/com/android/tools/build/gradle/1.1.2/gradle-1.1.2.pom
file:/home/roman/Documents/softs/android-studio/gradle/m2repository/com/android/tools/build/gradle/1.1.2/gradle-1.1.2.jar
Required by:
Yoki:facebook:unspecified
So I moved into the specified directory and then there is only this:
所以我移动到指定的目录,然后只有这个:
$> ls
1.0.0 1.1.0
$> pwd
/home/roman/Documents/softs/android-studio/gradle/m2repository/com/android/tools/build/gradle
How can I update the gradle plugin?
如何更新 gradle 插件?
采纳答案by Gabriele Mariotti
Change your buildscript
block. You have to specify alsoin this block the repositories.
改变你的buildscript
街区。您必须指定同样在此块的存储库。
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
}
}
Also you can use the last version:
您也可以使用最新版本:
classpath 'com.android.tools.build:gradle:1.1.3'
回答by Jintin
There are three type of dependency in Android gradle file.
Android gradle 文件中存在三种类型的依赖项。
1. Module dependency: other local project.
1. 模块依赖:其他本地项目。
2. Local dependency: in your sdk path extras folder.
2. 本地依赖:在您的 sdk 路径 extras 文件夹中。
3. Remote dependency: JCenter, MavenCenter or third party maven path.
3.远程依赖:JCenter、MavenCenter或第三方maven路径。
'com.android.tools.build:gradle' is local dependency, so you have to check your sdk and update.
'com.android.tools.build:gradle' 是本地依赖,所以你必须检查你的 sdk 并更新。
P.S. If you tired with the version issue, you can try andle.
PS 如果你厌倦了版本问题,你可以试试andle。
It's an open source project to update your Android dependency version automatically.
它是一个开源项目,可以自动更新您的 Android 依赖项版本。
See https://github.com/Jintin/andlefor more information
有关更多信息,请参阅https://github.com/Jintin/andle
回答by Jayakrishnan PM
A regularly updated online guide. Explains you which is the latest gradle version and the source of releases. How to update using single text edits in gradle files.
定期更新的在线指南。向您解释哪个是最新的 gradle 版本和发行版的来源。如何在 gradle 文件中使用单个文本编辑进行更新。
Guide to get updated to latest gradle version