android - Gradle 发出错误 "Could not create plugin of type ' AppPlugin'"

标签 android gradle

我正在尝试使用 gradle 创建一个简单的 android 项目。我在一台装有 Debian GNU/Linux 7 'wheezy' 的电脑上工作。

我遵循了 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

我遵循了规范:

  • Gradle 1.9
  • 插件 0.7
  • SDK 17+(实际上是 19)

我也重新开始了一个项目,我展示的结果是由命令gradle tasks发出的,如文档所示。

我也试过gradle 1.10,结果还是一样。

偶数 this question没用,因为它通过“升级”到 gradle 1.6 解决了(我知道插件 0.7 至少需要 gradle 1.9)。

android-studioIntelliJ Idea 中出现相同错误后,我尝试了此操作。

编辑:我还尝试了两个 IDE 中的新项目,但遇到了同样的问题。但最让我惊讶的是,这两个 IDE 都以包装形式使用 gradle 1.8。我试图让他们两个都使用我的本地 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')
}

最佳答案

Google 在 Gradle plugin 的 0.7.2 版中犯了一个错误:

Note: 0.7.2 requires Java7. This is a mistake. Use 0.7.3 instead.

0.7.3 版重新启用 Java6 支持。在我的构建文件中声明 Gradle 0.7.3 确实为我解决了这个问题。

没有人是完美的:)

http://tools.android.com/tech-docs/new-build-system

关于android - Gradle 发出错误 "Could not create plugin of type ' AppPlugin'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20811514/

相关文章:

java - 使用 Chat GPT API 的 Android Studio 项目返回 403 错误

android - 获取 MultiDex 错误,即使在设置 Min SDK 21 之后

gradle - 子build.gradle在afterEvaluate事件中不评估

android - 评论gradle依赖

android - 升级到 gradle 3.3 和 android 构建工具 2.3.0 时收到构建错误

android - 尝试添加包时出现错误 "duplicate entry: com/google/android/gms/internal/zzble.class"

android - 默认的android :sharedUserId set if android:sharedUserId was not set是什么

Android:Strings.xml 中具有 Double 值的字符串格式

android - 无法通过Google Services Google Maps V2运行Android项目

android - 圆形 ImageView 显示方形图像