2016-04-17 78 views
0

我閱讀文檔,但我無法做到。我正在使用Android Studio 2.0穩定版本。Android Gradle dexcount-gradle-plugin

這是我的項目級的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 
} 

,這是應用程序模塊級的build.gradle文件:

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 

這個錯誤的解決方案是什麼?

+1

您是否嘗試過應用android插件? :) – JesusFreke

+0

android plugin已經被應用了,但是我改變了「apply plugin:'com.android.application'」和「apply plugin:'com.getkeepsafe.dexcount'」這一行並且它已經工作了。感謝您的建議:) – okarakose

+0

請不要編輯您的問題的解決方案。相反,請將其作爲下面的單獨答案發布。 – Matt

回答

3

SOLUTION

我轉移的

線 「應用插件: 'com.android.application'」

「應用插件:「com.getkeepsafe。 dexcount'「

它的工作

+1

按照OmerKarakose的建議將應用程序插件移動到dexcount插件上方 –

0

據記載在Dex count's GitHub repo:如你所說

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

因此,只要確保了Android插件是地塞米松計數插件之前。

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