我會建議暫時使用多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_id_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
...
另一種方法是編寫使用dexlib2讀取DEX文件和打印出來的方法refereneces一個小工具。
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)));
}
}
}
這將在一個簡單的列表打印出來的方法引用:
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
...
https://github.com/mihaip/dex-method-counts可能是有用的。 – fadden