Android Gradle 发出错误“无法创建‘AppPlugin’类型的插件”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20811514/
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
Gradle is issuing an error "Could not create plugin of type 'AppPlugin'"
提问by aBarocio80
I'm trying to create a simple android project with gradle. I work in a computer with Debian GNU/Linux 7 'wheezy'.
我正在尝试使用 gradle 创建一个简单的 android 项目。我在一台装有 Debian GNU/Linux 7 'wheezy' 的计算机上工作。
I followed the recomendations in Gradle Plugin User Guide - Android Tools Project Site, but it casts an error:
我遵循Gradle Plugin User Guide - Android Tools Project Site 中的建议,但它抛出了一个错误:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/alex/Proyectos/MyLogin/build.gradle' line: 11
* What went wrong:
A problem occurred evaluating root project 'MyLogin'.
> Could not create plugin of type 'AppPlugin'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.817 secs
I followed the specifications:
我遵循了规范:
- Gradle 1.9
- Plugin 0.7
- SDK 17+ (actually 19)
- 摇篮 1.9
- 插件 0.7
- SDK 17+(实际 19)
I also started a project anew, and the results I showed were issued by the command gradle tasks
as shown in the documentation.
我也重新开始了一个项目,我显示的结果是由gradle tasks
文档中显示的命令发出的。
I also tried gradle 1.10, but the result is the same.
我也试过 gradle 1.10,但结果是一样的。
Even this questionwas not usefull, since it solved with 'upgrading' to gradle 1.6 (I understand that plugin 0.7 requires at least gradle 1.9).
即使这个问题也没有用,因为它通过“升级”到 gradle 1.6 解决了(我知道插件 0.7 至少需要 gradle 1.9)。
I tried this after failing with the same error in android-studioand IntelliJ Idea.
我在android-studio和IntelliJ Idea 中以相同的错误失败后尝试了这个。
EDIT:I also tried with new projects in both IDEs, and got the same issue. But what most surprises me is that both IDEs use gradle 1.8 in their wrapped form. I tried to cinfigure both of them to use my local gradle install, but still the same issue.
编辑:我也在两个 IDE 中尝试了新项目,但遇到了同样的问题。但最令我惊讶的是,这两个 IDE 都以包装形式使用 gradle 1.8。我试图让他们都使用我的本地 gradle 安装,但仍然是同样的问题。
What am I doing wrong? Is it a bug? How can I avoid the problem?
我究竟做错了什么?这是一个错误吗?我怎样才能避免这个问题?
Please, help me.
请帮我。
EDIT:Here is my build.gradle
编辑:这是我的build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 14
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
}
sourceCompatibility = 1.6
version = '0.1'
dependencies {
compile 'com.android.support:support-v4:18.0.0'
//compile project(':core')
}
采纳答案by SK9
Google made a mistake with version 0.7.2 of the Gradle plugin:
Google 在Gradle 插件的0.7.2 版中犯了一个错误:
Note: 0.7.2 requires Java7. This is a mistake. Use 0.7.3 instead.
注意:0.7.2 需要 Java7。这是个错误。请改用 0.7.3。
Release 0.7.3 re-enables Java6 support. Declaring Gradle 0.7.3 in my build files does indeed resolve this for me.
0.7.3 版重新启用 Java6 支持。在我的构建文件中声明 Gradle 0.7.3 确实为我解决了这个问题。
No one is perfect :)
没有人是完美的 :)
回答by Vasile Jureschi
Use Gradle 1.9 instead of Gradle 1.10. There is an issue with 1.10 : https://code.google.com/p/android/issues/detail?id=63822
使用 Gradle 1.9 而不是 Gradle 1.10。1.10 存在问题:https: //code.google.com/p/android/issues/detail?id =63822
Also answered here:
也在这里回答:
在 Gradle 中应用 Android 插件时找不到 org.gradle.api.artifacts.result.ResolvedModuleVersionResult
回答by JJD
I got it working using Gradle 1.10 with the Gradle plugin 0.8.0.
我使用 Gradle 1.10 和 Gradle 插件 0.8.0 让它工作。
// /build.gradle
// Top-level build file where you can add configuration
// options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
...
...
# /gradle/wrapper/gradle-wrapper.properties.
#Sat Feb 01 20:41:29 CET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
回答by Jon
If you're using the command line to create the project like so:
如果您使用命令行创建项目,如下所示:
android create project -g -v 1.2.2 --target 1 --name rtest --path rtest --activity MainActivity --package com.mydomain.rtest
The project is created to use version 1.2.2 of the android-gradle-plugin, but the project is initialised with gradle 1.12, which isn't compatible.
该项目是为使用 android-gradle-plugin 的 1.2.2 版创建的,但该项目是使用 gradle 1.12 初始化的,它不兼容。
To fix it, do the following:
要修复它,请执行以下操作:
- Open
rtest/gradle/wrapper/gradle-wrapper.properties
and setdistributionUrl
to the release you want; for example:http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
(don't forget to escape the colon - yes, that makes me smile too); - Open
build.gradle
and changerunProguard false
tominifyEnabled false
; ./gradlew clean && ./gradlew assembleDebug
- I also remove the hidden
.gradle
folder, but I'm not sure if it's necessary
- 打开
rtest/gradle/wrapper/gradle-wrapper.properties
并设置distributionUrl
为您想要的版本;例如:(http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
不要忘记转义冒号 - 是的,这也让我微笑); - 打开
build.gradle
并更改runProguard false
为minifyEnabled false
; ./gradlew clean && ./gradlew assembleDebug
- 我也删除了隐藏
.gradle
文件夹,但我不确定是否有必要
And it all works again.
这一切又重新开始了。
回答by Eric Woodruff
You can also get this error if you update your system gradle and forget to update the Android Studio gradle home.
如果您更新系统 gradle 并忘记更新 Android Studio gradle home,您也可能收到此错误。
回答by Blundell
If you are attempting to update your Gradle 1.9 project to Gradle 1.10 using
如果您尝试使用以下方法将 Gradle 1.9 项目更新到 Gradle 1.10
task wrapper(type: Wrapper) {
gradleVersion = '1.10'
}
and command ./gradlew wrapper
you will get the same error as above.
和命令./gradlew wrapper
你会得到与上面相同的错误。
Solution is to install Gradle 1.10 onto your machine and upgrade your project not using the wrapper
解决方案是将 Gradle 1.10 安装到您的机器上并升级您的项目而不使用包装器
gradle wrapper
gradle wrapper
回答by Isham
For those who are using 2.1 version of studio, replace classpath 'com.android.tools.build:gradle:2.1.0-rc1' with classpath 'com.android.tools.build:gradle:2.1.0'. This solved my problem.
对于使用 2.1 版 studio 的用户,请将 classpath 'com.android.tools.build:gradle:2.1.0-rc1' 替换为 classpath 'com.android.tools.build:gradle:2.1.0'。这解决了我的问题。
回答by Splaktar
I got this today when running gradle assembleRelease. I had installed the Ubuntu default of gradle-1.4. This didn't work, so I tried the latest gradle-1.12 and got the same issue.
我今天在运行 gradle assembleRelease 时得到了这个。我已经安装了 Ubuntu 默认的 gradle-1.4。这不起作用,所以我尝试了最新的 gradle-1.12 并遇到了同样的问题。
Downloading and using gradle-1.10 (and matching my gradle-wrapper.properties file to that version) resolved the issue.
下载并使用 gradle-1.10(并将我的 gradle-wrapper.properties 文件与该版本匹配)解决了该问题。
This is with Android Studio 0.5.8.
这是 Android Studio 0.5.8。
回答by Pankaj Nimgade
Ok i guess android studio has answer for this to get this bug out using GUI,
好的,我想 android studio 对此有答案,可以使用 GUI 解决此错误,
after updating the plugins i was facing another issues while building,
更新插件后,我在构建时遇到了另一个问题,
so changes the gradle setting
to default as shown in the image,
After this build was successful.
此构建成功后。
回答by Abhilash
Go to dependencies and just change the dependencies classpath to classpath 'com.android.tools.build:gradle:2.0.0-beta6' Rest Gradle will take care. Happy coding :)
转到依赖项并将依赖项类路径更改为类路径 'com.android.tools.build:gradle:2.0.0-beta6' Rest Gradle 会处理。快乐编码:)