简体   繁体   English

Android:如何更新build.gradle?

[英]Android: How to update build.gradle?

I need gradle ver 2.1.4 so I tried changing 我需要gradle ver 2.1.4,所以我尝试改变

classpath 'com.android.tools.build:gradle:2.1.3' classpath'com.android.tools.build:grad:2.1.3'

to

classpath 'com.android.tools.build:gradle:2.1.4' classpath'com.android.tools.build:grad:2.1.4'

but it didn't work. 但它不起作用。 I also tried this method http://devdeeds.com/update-gradle-plugin-android-studio/ but that didn't work either. 我也尝试过这种方法http://devdeeds.com/update-gradle-plugin-android-studio/,但这也不起作用。 This is the error that I am getting 这是我得到的错误

Error:Could not find com.android.tools.build:gradle:2.1.4. 错误:找不到com.android.tools.build:gradle:2.1.4。 Searched in the following locations: file:/C:/Users/Reimu/Downloads/android-studio-ide-145.3200535-windows/android-studio/gradle/m2repository/com/android/tools/build/gradle/2.1.4/gradle-2.1.4.pom file:/C:/Users/Reimu/Downloads/android-studio-ide-145.3200535-windows/android-studio/gradle/m2repository/com/android/tools/build/gradle/2.1.4/gradle-2.1.4.jar https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.4/gradle-2.1.4.pom https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.4/gradle-2.1.4.jar Required by: :MyApp:unspecified 在以下位置搜索:file:/ C:/Users/Reimu/Downloads/android-studio-ide-145.3200535-windows/android-studio/gradle/m2repository/com/android/tools/build/gradle/2.1.4/ gradle-2.1.4.pom文件:/ C:/Users/Reimu/Downloads/android-studio-ide-145.3200535-windows/android-studio/gradle/m2repository/com/android/tools/build/gradle/2.1.4 /gradle-2.1.4.jar https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.4/gradle-2.1.4.pom https://jcenter.bintray.com/com /android/tools/build/gradle/2.1.4/gradle-2.1.4.jar要求:: MyApp:未指定

I can't run any projects without this being updated apparently. 如果没有明显更新,我就无法运行任何项目。 Any help is appreciated 任何帮助表示赞赏

The classpath 'com.android.tools.build:gradle:2.1.3' is not for Gradle itself, but the Gradle Android build plugin that you apply with the apply plugin: 'com.android.application' or apply plugin: 'com.android.library' in your module's build.gradle file. classpath 'com.android.tools.build:gradle:2.1.3'不适用于Gradle本身,而是适用于apply plugin: 'com.android.application'Gradle Android构建 apply plugin: 'com.android.application'或者apply plugin: 'com.android.library'在模块的build.gradle文件中。

If you want to use another version of gradle in your project, reconfigure your gradle wrapper . 如果要在项目中使用其他版本的gradle ,请重新配置gradle包装器 Search for the /gradle/wrapper/gradle-wrapper.properties file in your project root, and apply the correct distributionUrl , for example: 在项目根目录中搜索/gradle/wrapper/gradle-wrapper.properties文件,并应用正确的distributionUrl ,例如:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

For the 2.14.1 version of gradle . 对于2.14.1版本的gradle This is probably what you need, because there is no such thing as Gradle v. 2.1.4 . 这可能就是你所需要的,因为没有Gradle v.2.1.4这样的东西 There is also no Android Gradle plugin v. 2.1.4 . 没有Android Gradle插件v.2.1.4

And if it turns out, that you need the newest android grade build plugin, then change your class path to 'com.android.tools.build:gradle:2.2.0-beta2' . 如果结果是,您需要最新的Android级构建插件,然后将您的类路径更改为'com.android.tools.build:gradle:2.2.0-beta2' Version 2.1.3 is currently the newest stable version. 2.1.3版本是目前最新的稳定版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM