简体   繁体   中英

Android Gradle dexcount-gradle-plugin

I read the documentation but I could not make it. I am using Android Studio 2.0 Stable version.

This is my project level build.gradle file :

// 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
}

and this is app module level build.gradle file :

    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'
}

this is giving error everytime :

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

what is the solution of this error ?

SOLUTION

I shifted the line of

"apply plugin: 'com.android.application'"

with

"apply plugin: 'com.getkeepsafe.dexcount'"

and it's worked

It is documented in Dex count's GitHub repo :

// make sure this line comes *after* you apply the Android plugin
apply plugin: 'com.getkeepsafe.dexcount'

So as you said, just make sure that the Android plugin is before the Dex count plugin.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM