Android 导致DexIndexOverflowException的方法引用列表
我正面临一个导致Android 导致DexIndexOverflowException的方法引用列表,android,android-studio,android-multidex,Android,Android Studio,Android Multidex,我正面临一个导致com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]:65536中的问题 我知道使用multiDexEnabled,但我不想实现或使用它,因为它有一些限制 其中之一是: 使用multidex的应用程序可能无法在运行multidex的设备上启动 Android 4.0(API级别14)之前的平台版本到期 一个Dalvik Linearloc错误(发行号22586)。如果您的目标是API 级别早于14,请确保使用这些 作
com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]:65536
中的问题
我知道使用multiDexEnabled
,但我不想实现或使用它,因为它有一些限制
其中之一是:
使用multidex的应用程序可能无法在运行multidex的设备上启动
Android 4.0(API级别14)之前的平台版本到期
一个Dalvik Linearloc错误(发行号22586)。如果您的目标是API
级别早于14,请确保使用这些
作为应用程序的平台版本可能在以下位置出现问题:
启动或加载特定的类组时。代码
收缩可以减少或可能消除这些潜在问题
被谷歌引用
我想知道一种方法,可以显示导致此问题的方法引用列表。这样我可以在导入项目中已有的库时删除这些模块
例如:
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
我建议暂时使用multi-dex,然后使用baksmali对生成的dex文件进行带注释的十六进制转储。带注释的十六进制转储将包括方法参考列表
baksmali -N -D out.dump -e classes.dex myapp.apk
baksmali -N -D out2.dump -e classes2.dex myapp.apk
您需要在2个转储文件中查找“method\u id\u item section”。本节包含dex文件中使用的方法引用的完整列表。看起来像
|-----------------------------
|method_id_item section
|-----------------------------
|
|[0] method_id_item
003c38: 0500 | class_idx = type_id_item[5]: Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;
003c3a: b000 | proto_idx = proto_id_item[176]: (I)V
003c3c: 1900 0000 | name_idx = string_id_item[25]: <init>
|[1] method_id_item
003c40: 0500 | class_idx = type_id_item[5]: Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;
003c42: d500 | proto_idx = proto_id_item[213]: (Landroid/graphics/Canvas;)V
003c44: df02 0000 | name_idx = string_id_item[735]: draw
|[2] method_id_item
003c48: 0500 | class_idx = type_id_item[5]: Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;
003c4a: a400 | proto_idx = proto_id_item[164]: ()V
003c4c: 4103 0000 | name_idx = string_id_item[833]: generatePatternBitmap
|[3] method_id_item
003c50: 0500 | class_idx = type_id_item[5]: Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;
003c52: 4500 | proto_idx = proto_id_item[69]: ()Landroid/graphics/Rect;
003c54: 4e03 0000 | name_idx = string_id_item[846]: getBounds
|[4] method_id_item
003c58: 0500 | class_idx = type_id_item[5]: Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;
003c5a: 0c00 | proto_idx = proto_id_item[12]: ()I
003c5c: 8403 0000 | name_idx = string_id_item[900]: getOpacity
...
|-----------------------------
|方法\u id\u项目部分
|-----------------------------
|
|[0]方法\u id\u项
003c38:0500 | class|idx=type|id|u项[5]:Lafzkl/development/mColorPicker/drawable/alphapattern drawable;
003c3a:b000 | proto_idx=proto_id_项目[176]:(I)V
003c3c:1900 0000 | name_idx=字符串_id_项[25]:
|[1] 方法\u id\u项
003c40:0500 | class_idx=type_id_item[5]:Lafzkl/development/mColorPicker/drawable/alphapattern drawable;
003c42:d500 | proto_idx=proto_id_项[213]:(Landroid/graphics/Canvas;)V
003c44:df02 0000 | name_idx=字符串_id_项目[735]:绘图
|[2] 方法\u id\u项
003c48:0500 | class|idx=type|id|u项[5]:Lafzkl/development/mColorPicker/drawable/alphapattern drawable;
003c4a:a400 | proto_idx=proto_id_项目[164]:()V
003c4c:4103 0000 | name_idx=string_id_item[833]:generatePatternBitmap
|[3] 方法\u id\u项
003c50:0500 | class|idx=type|id|u项[5]:Lafzkl/development/mColorPicker/drawable/alphapattern drawable;
003c52:4500 | proto_idx=proto_id_项[69]:()Landroid/graphics/Rect;
003c54:4e03 0000 | name_idx=string_id_item[846]:getBounds
|[4] 方法\u id\u项
003c58:0500 | class|idx=type|id|u项[5]:Lafzkl/development/mColorPicker/drawable/alphapattern drawable;
003c5a:0C000 | proto_idx=proto_id_项目[12]:()I
003c5c:8403 0000 | name_idx=string_id_item[900]:getOpacity
...
另一种方法是使用编写一个小工具来读取dex文件并打印出方法references
public class DumpMethods {
public static void main(String[] args) throws IOException {
DexBackedDexFile dexFile = DexFileFactory.loadDexFile(args[0], 15);
for (int i=0; i<dexFile.getMethodCount(); i++) {
System.out.println(ReferenceUtil.getMethodDescriptor(new DexBackedMethodReference(dexFile, i)));
}
}
}
公共类转储方法{
公共静态void main(字符串[]args)引发IOException{
DexBackedDexFile dexFile=DexFileFactory.loadDexFile(args[0],15);
对于(int i=0;i(i)V
Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;->draw(Landroid/graphics/Canvas;)V
Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;->generatePatternBitmap()V
Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;->getBounds()Landroid/graphics/Rect;
Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;->getOpacity()I
...
可能有用。
Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;-><init>(I)V
Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;->draw(Landroid/graphics/Canvas;)V
Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;->generatePatternBitmap()V
Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;->getBounds()Landroid/graphics/Rect;
Lafzkl/development/mColorPicker/drawables/AlphaPatternDrawable;->getOpacity()I
...