Plugins Android Gradle dexcount Gradle插件

Plugins Android Gradle dexcount Gradle插件,plugins,android-gradle-plugin,dex,Plugins,Android Gradle Plugin,Dex,我读了文件,但没能完成。我使用的是Android Studio 2.0稳定版 这是我的项目级build.gradle文件: // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() mavenCentral() } dep

我读了文件,但没能完成。我使用的是Android Studio 2.0稳定版

这是我的项目级build.gradle文件:

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

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0'
        classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
    buildscript {
    repositories {
        mavenCentral() // or jcenter()
    }

    dependencies {
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.4.4'
    }
}

apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.hugo'

dexcount {
    format = "list"
    includeClasses = false
    includeFieldCount = true
    includeTotalMethodCount = false
    orderByMethodCount = false
    verbose = false
    maxTreeDepth = Integer.MAX_VALUE
    teamCityIntegration = false
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "my_package_name"
        minSdkVersion 11
        targetSdkVersion 23
        versionCode 1
        versionName "1.0.0"
    }
    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            debuggable false
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions{
        exclude 'META-INF/maven/commons-io/commons-io/pom.xml'
        exclude 'META-INF/maven/commons-io/commons-io/pom.properties'
    }
}

ext {
    supportLibVersion = '23.3.0'
    googlePlayServicesVersion = '8.4.0'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
    compile "com.android.support:percent:${supportLibVersion}"
    compile "com.android.support:cardview-v7:${supportLibVersion}"

    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'

    // eventbus
    compile 'org.greenrobot:eventbus:3.0.0'

    // rate me dialog
    compile 'com.github.hotchemi:android-rate:0.5.6'

    // apache commons-io
    compile group: 'commons-io', name: 'commons-io', version: '2.0.1'
}
这是应用程序模块级build.gradle文件:

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

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0'
        classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
    buildscript {
    repositories {
        mavenCentral() // or jcenter()
    }

    dependencies {
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.4.4'
    }
}

apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.hugo'

dexcount {
    format = "list"
    includeClasses = false
    includeFieldCount = true
    includeTotalMethodCount = false
    orderByMethodCount = false
    verbose = false
    maxTreeDepth = Integer.MAX_VALUE
    teamCityIntegration = false
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "my_package_name"
        minSdkVersion 11
        targetSdkVersion 23
        versionCode 1
        versionName "1.0.0"
    }
    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            debuggable false
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions{
        exclude 'META-INF/maven/commons-io/commons-io/pom.xml'
        exclude 'META-INF/maven/commons-io/commons-io/pom.properties'
    }
}

ext {
    supportLibVersion = '23.3.0'
    googlePlayServicesVersion = '8.4.0'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
    compile "com.android.support:percent:${supportLibVersion}"
    compile "com.android.support:cardview-v7:${supportLibVersion}"

    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'

    // eventbus
    compile 'org.greenrobot:eventbus:3.0.0'

    // rate me dialog
    compile 'com.github.hotchemi:android-rate:0.5.6'

    // apache commons-io
    compile group: 'commons-io', name: 'commons-io', version: '2.0.1'
}
每次都会出现以下错误:

Error:(11, 0) Dexcount plugin requires the Android plugin to be configured

此错误的解决方案是什么?

解决方案

我改变了路线

“应用插件:'com.android.application'”

“应用插件:'com.getkeepsafe.dexcount'”


而且它是有效的

解决方案

我改变了路线

“应用插件:'com.android.application'”

“应用插件:'com.getkeepsafe.dexcount'”

它已经工作了

记录在:

正如你所说的,只需确保Android插件在Dex count插件之前

apply plugin: 'com.android.application'
apply plugin: 'com.getkeepsafe.dexcount'
记录在:

正如你所说的,只需确保Android插件在Dex count插件之前

apply plugin: 'com.android.application'
apply plugin: 'com.getkeepsafe.dexcount'

你试过应用android插件吗?:)android插件已经应用了,但我将“应用插件:'com.android.application'”一行改为“应用插件:'com.getkeepsafe.dexcount'”,并且成功了。感谢您的建议:)请不要在您的问题中编辑解决方案。相反,将其作为一个单独的答案贴在下面。@Matt好的,谢谢。你试过应用android插件吗?:)android插件已经应用了,但我将“应用插件:'com.android.application'”一行改为“应用插件:'com.getkeepsafe.dexcount'”,并且成功了。感谢您的建议:)请不要在您的问题中编辑解决方案。相反,请将其作为单独的答案发布在下面。@Matt好的,我这样做了,谢谢。按照OmerKarakose的建议将应用程序插件移动到dexcount插件上方将应用程序插件移动到OmerKarakose建议的dexcount插件上方