Gradle:未找到id为’android-library’的插件

我正在尝试使用Gradle自动化我的项目.

我有几个应用程序和一个库项目.
在仔细阅读了official doc之后,这是我的build.gradle的简化视图:

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "http://saturday06.github.io/gradle-android-scala-plugin/repository/snapshot"
        }
    }
    dependencies {
        // 0.8.3 con Gradle 1.10
        classpath 'org.gradle.api.plugins:gradle-android-plugin:1.2.1'
    }
}

apply plugin: 'idea'

project(':MyApp') {
    ext.apl = true
}

project(':MyLibrary') {
    ext.apl = false
}

subprojects {
    if (project.apl) {
        apply plugin: 'android'
        dependencies {
            compile 'ch.acra:acra:4.5.0'
        }
    }
    if (project.scala) {
        apply plugin: 'android-scala'
        scala {
            target "jvm-1.7"
            addparams '-feature'
        }
    } else {
        apply plugin: 'android-library'
    }
    android {
        compileSdkVersion 17
        buildToolsVersion '19.1.0'

        signingConfigs { ... }
        defaultConfig {
            minSdkVersion 8
            targetSdkVersion 17
        }

        sourceSets {
            compileOptions {
                sourceCompatibility JavaVersion.VERSION_1_7
                targetCompatibility JavaVersion.VERSION_1_7
            }
        }

        buildTypes {
            debug {
                runProguard false
                proguardFile file('proguard-rules.txt')
                signingConfig signingConfigs.depurar
            }

            release {
                runProguard true
                proguardFile file('proguard-rules.txt')
                signingConfig signingConfigs.entregar
            }
        }
    }
}

project(':MyLibrary') {
    dependencies {
        compile "com.github.tony19:logback-android-core:1.1.1-2"
        compile "com.github.tony19:logback-android-classic:1.1.1-2"
        compile "org.slf4j:slf4j-api:1.7.6"

    }
}

project(':MyApp') {
    dependencies {
        compile 'com.android.support:appcompat-v7:19.1.0'
        compile('org.apache.httpcomponents:httpmime:4.1.1') {
            transitive = false
        }
        compile project(':Bibl')
    }
}

我的settings.gradle是:

include 'MyLibrary', 'MyApp'

只有一个build.gradle.

问题是Gradle抱怨说

Plugin with id 'android-library' not found

每当我尝试使用这个插件.
使用apply plugin:’android’没有问题.

文档明确指出,必须使用库的“android-library”.
我正在使用Gradle 1.10.

对于像1.2.1这样的最新版gradle-android-plugin,doc是否已过时?因为官方文档适用于0.9版.

解决方法:

Is the doc outdated for newest versions of gradle-android-plugin like 1.2.1?

引用the documentation for gradle-android-plugin

We are very sorry to announce that development of this plugin has been discontinued. Google has created their own Android development toolchain based on Gradle, which supercedes this plugin.

Please see 07001 for further information.

我通常将android-library与官方Gradle for Android插件相关联;我不知道弃用的gradle-android-plugin是否支持它.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐