Dexcount Gradle Plugin —— 计算 APK 方法数量的插件
2018-01-19 12:27 阅读(339)

Dexcount Gradle Plugin 是一款 Gradle 插件,用于计算每个版本的 APK 或 AAR 中的方法引用数量。

随着项目越来越大,Android 应用不得不面对 64k 方法数限制的问题,这个插件可帮助你监视 app 中的方法数增长情况,并避免通过消除方法或启用 multidex 来解决问题。

用法

在 app/build.gradle 中添加

buildscript {
    repositories {
        mavenCentral() // or jcenter()    }

    dependencies {
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'    }
}// make sure this line comes *after* you apply the Android pluginapply plugin: 'com.getkeepsafe.dexcount'

输出示例

> ./gradlew assembleDebug

...buildspam...
:app:compileDebugSources
:app:preDexDebug UP-TO-DATE
:app:dexDebug
:app:packageDebug
:app:zipalignDebug
:app:assembleDebug
Total methods in MyApp-debug.apk: 58930 (89.92% used)
Total fields in MyApp-debug.apk:  27507 (41.97% used)
Methods remaining in MyApp-debug.apk: 6605Fields remaining in MyApp-debug.apk:  38028BUILD SUCCESSFUL

Total time: 33.017 secs


下载:https://github.com/KeepSafe/dexcount-gradle-plugin