隨著項目代碼量的增大,有時會遇到方法數(shù)限制,如:
The number of method references in a .dex file cannot exceed 64K
或
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]
這時,就像知道項目到底有多少個方法~
那項目的方法數(shù)怎么統(tǒng)計呢消恍?
- 在項目(project)級的
build.gradle
中添加dexcount-gradle-plugin:0.6.4
:
buildscript {
repositories {
//***
}
dependencies {
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.4'
}
}
- 在app(module)的
build.gradle
中添加apply plugin: 'com.getkeepsafe.dexcount'
:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.getkeepsafe.dexcount'
-
編譯運行項目,即可看到方法數(shù)統(tǒng)計信息。
方法數(shù)統(tǒng)計
over~