如何查看 android 中的 dex 计数?
How can I check the dex count in android?
我的项目的gradle文件如下。
android {
compileSdkVersion 23
buildToolsVersion "25.0.1"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
}
在 Android Studio 中 "Generate Signed APK" 时,我可以看到 DexIndexOverflowException。
Error:Execution failed for task ':MyProject:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
我已经知道这个错误并阅读了文档(https://developer.android.com/studio/build/multidex.html)。
只是我想检查一下超过了多少dex。
例如:
trouble writing output:
Too many field references: 99999; max is 65536.
You may try using --multi-dex option.
请找到解决方案。
Android studio 有一个名为 Android Methods Count
的插件,它将显示每个依赖项的方法数量。
还有一个 cli 工具,有更多选项,请访问
https://github.com/mihaip/dex-method-counts
使用此插件获取每次构建时 APK 中方法引用的数量。
Android Studio 有一个 APK analyzer 显示此信息,不需要 gradle 插件。
我修改了 dx.jar 源代码以显示方法计数。
https://github.com/b1uec0in/dx
输出样本
string ID count: 91,857
type ID count: 12,636
proto ID count: 18,417
field ID count: 72,011 (max:65535 +6476)
method ID count: 81,181 (max:65535 +15646)
用这个 dx.jar 替换你的 dx.jar。
看看this。我一直在寻找相同的东西,并在这里找到了答案。基本上,您必须生成项目的 APK,然后转到 Build->Analyze APK,在结果中单击 classes.dex,然后,您将在下面看到项目定义和引用了多少方法。
我的项目的gradle文件如下。
android {
compileSdkVersion 23
buildToolsVersion "25.0.1"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
}
在 Android Studio 中 "Generate Signed APK" 时,我可以看到 DexIndexOverflowException。
Error:Execution failed for task ':MyProject:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
我已经知道这个错误并阅读了文档(https://developer.android.com/studio/build/multidex.html)。
只是我想检查一下超过了多少dex。
例如:
trouble writing output:
Too many field references: 99999; max is 65536.
You may try using --multi-dex option.
请找到解决方案。
Android studio 有一个名为 Android Methods Count
的插件,它将显示每个依赖项的方法数量。
还有一个 cli 工具,有更多选项,请访问 https://github.com/mihaip/dex-method-counts
使用此插件获取每次构建时 APK 中方法引用的数量。
Android Studio 有一个 APK analyzer 显示此信息,不需要 gradle 插件。
我修改了 dx.jar 源代码以显示方法计数。
https://github.com/b1uec0in/dx
输出样本
string ID count: 91,857
type ID count: 12,636
proto ID count: 18,417
field ID count: 72,011 (max:65535 +6476)
method ID count: 81,181 (max:65535 +15646)
用这个 dx.jar 替换你的 dx.jar。
看看this。我一直在寻找相同的东西,并在这里找到了答案。基本上,您必须生成项目的 APK,然后转到 Build->Analyze APK,在结果中单击 classes.dex,然后,您将在下面看到项目定义和引用了多少方法。