DexcountGradlePlugin是一款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:assembleDebugTotal 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 SUCCESSFULTotal time: 33.017 secs
评论