android 统计项目方法数

随着项目代码量的增大,有时会遇到方法数限制,如:
The number of method references in a .dex file cannot exceed 64K

com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]
这时,就像知道项目到底有多少个方法~

那项目的方法数怎么统计呢?
  1. 在项目(project)级的 build.gradle 中添加 dexcount-gradle-plugin:0.6.4
buildscript {
    repositories {
        //***
    }
    dependencies {
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.4'
    }
}
  1. 在app(module)的 build.gradle中添加 apply plugin: 'com.getkeepsafe.dexcount' :
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.getkeepsafe.dexcount'
  1. 编译运行项目,即可看到方法数统计信息。


    方法数统计

over~

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容