错误:(11,0)不允许在使用标准Gradle生命周期插件时声明自定义“清理”任务

时间:2017-11-03 10:58:56

标签: java android build.gradle android-studio-2.3

您好我现在正在使用2个模块的Android应用程序工作,第一个是我的应用程序与buildgradle像

top: -166px;

第二个模块是我的项目中包含的库,这里是buildgradle(模块:库):

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.alexvasilkov:android-sign-release:0.8.1'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'com.alexvasilkov.sign'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "dz.condorpos"
        minSdkVersion 17
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        release {
            storeFile file("foldable-layout-release-key.keystore")
            keyAlias "release"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile project(':library')
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.squareup.okhttp3:okhttp:3.8.1'
    compile 'com.github.barteksc:android-pdf-viewer:1.4.0'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.alexvasilkov:android-commons:2.0.2'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.afollestad:easyvideoplayer:0.3.0'
    compile 'com.google.firebase:firebase-auth:10.0.1'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.google.firebase:firebase-database:10.0.1'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
    compile 'com.google.firebase:firebase-storage:10.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'

    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

项目buildgradle就像:

apply plugin: 'com.android.library'
android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 25
    }
}
// New version can be uploaded with 'gradlew clean :library:jar :library:uploadArchives'
apply from: 'gradle-mvn-push.gradle'

dependencies {
}

该项目一直工作到昨天,当我在我的app模块中添加了picasso的编译依赖项后,在gradle sync失败后显示了这个

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {

        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects { project ->
    repositories {
        jcenter()
        maven { url 'https://dl.bintray.com/drummer-aidan/maven' }
    }
    // Enabling checkstyle for all sub projects
    project == rootProject || project.afterEvaluate {
        project.apply plugin: 'checkstyle'

        project.extensions.getByName('checkstyle').with {
            toolVersion = '6.15'
            configFile file("${rootDir}/checkstyle.xml")
        }

        task checkstyle(type: Checkstyle) {
            source 'src'
            include '**/*.java', '**/*.xml'
            classpath = files()
        }

        project.tasks.getByName('check').dependsOn 'checkstyle'

        project.extensions.getByName('android').with {
            lintOptions {
                ignore 'GoogleAppIndexingWarning', 'ContentDescription'
            }
        }

    }
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
}

现在即使我删除毕加索仍然会发生错误当然我没有问过这个问题,经过长时间的研究我找到了一些解决方案,但没有像this那样工作 注意:我的项目的旧版本仍然使用相同的清洁任务正常工作,但经过一些gardle同步后我会遇到这个问题。

我想提前感谢您的帮助

1 个答案:

答案 0 :(得分:0)

经过大量研究,我发现我们只需要在bulid.gradle(Project)中注释干净任务行,如下所示:

   [//    task clean(type: Delete) {
        //        delete rootProject.buildDir
        //    }][1]