【问题标题】:failing building with gradle使用 gradle 构建失败
【发布时间】:2014-01-22 23:57:30
【问题描述】:

我创建了一个项目,并将以下内容添加到我的 build.gradle 文件中,我收到了此错误消息 A problem occurred evaluating root project NewsFeeder. Plugin with id android not found

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
}

android {
    compileSdkVersion 18
    buildToolsVersion '18'

    defaultConfig {
        targetSdkVersion 18
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

【问题讨论】:

  • 查看 Android 插件文档以了解如何引入 Android 插件。

标签: java android gradle


【解决方案1】:

这是你完整的 build.gradle 吗?

如果是这样,你就错过了

apply plugin: 'android'

通常高于存储库块。

另外我认为您需要 buildscript 块来确定要使用的 gradle。

示例 build.gradle 看起来像

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}

apply plugin: 'android'

repositories {
    maven {
        url 'https://github.com/Goddchen/mvn-repo/raw/master/'
    }
    mavenCentral()
}

dependencies {
    compile 'com.android.support:support-v13:13.0.+'
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    defaultConfig {
         minSdkVersion 16
         targetSdkVersion 19
    }

    ..... other configs .....
}

【讨论】:

    猜你喜欢
    • 2015-08-22
    • 2014-03-30
    • 1970-01-01
    • 2018-10-08
    相关资源
    最近更新 更多