2015-05-28 16 views
14

Tôi đã cố gắng để thiết lập jumboMode trong gradle cho dự án của tôi, có vẻ như có thể giải quyết các DexIndexOverflowException sau:DexIndexOverflowException: Không thể hợp nhất chỉ mục mới 65772 thành lệnh không jumbo !: Chế độ Jumbo? và/hoặc Multi-Dex? Điều gì đằng sau hiện trường?

com.android.dex.DexException: Không thể hợp nhất chỉ số mới 65536 thành một hướng dẫn phi jumbo!

DexIndexOverflowException: Không thể hợp nhất chỉ mục mới 65772 vào hướng dẫn không phải là jumbo!

1) Tùy chọn jumboMode thực sự làm gì ở hậu trường?

android { 
    ... 
    dexOptions { 
     jumboMode true 
    } 

} 

2) Tôi cũng nhận thấy rằng việc bật đa dex cũng có thể giải quyết cùng một vấn đề, lựa chọn đúng giữa hai cách tiếp cận này là gì?

android { 
    ... 
    defaultConfig { 
     ... 
     multiDexEnabled true 
    } 
} 
+2

Một số nền ở đây: http://stackoverflow.com/questions/21490382/does-the- android-art-runtime-có-cùng-phương pháp-giới hạn-giới hạn-dưới-dalvik / – fadden

Trả lời

2

"Jumbo" có nghĩa là "giống như trước đây, nhưng có số lượng lớn để tham khảo".

Hầu như bất cứ điều gì trong DEX-file tham chiếu với giá trị 16-bit (kể cả hiện tại bytecode là "đơn vị" 16-bit), vì vậy đây có thể giải quyết chỉ 65.536 đối tượng (phương pháp hoặc chuỗi), không còn nữa.

Nhưng ứng dụng có thể chứa nhiều chuỗi hơn! Làm thế nào để giải quyết giới hạn này? Các nhà phát triển Android chỉ thêm các mã mới có hậu tố "jumbo", vì vậy bạn có thể tham chiếu chuỗi với "const-string 16_bit_addr" hoặc "const-string 32_bit_addr" có thể tham chiếu 2^32 mục. Hiện nay https://source.android.com/devices/tech/dalvik/dalvik-bytecode "jumbo" hậu tố chỉ tồn tại cho các chuỗi (const-string/jumbo), nhưng trong tài liệu cũ bao gồm:

# 
# Extended-width opcodes 
# 

op 00ff const-class/jumbo   41c y type-ref  continue|throw 
op 01ff check-cast/jumbo   41c n type-ref  continue|throw 
op 02ff instance-of/jumbo   52c y type-ref  continue|throw 
op 03ff new-instance/jumbo   41c y type-ref  continue|throw 
op 04ff new-array/jumbo    52c y type-ref  continue|throw 
op 05ff filled-new-array/jumbo  5rc n type-ref  continue|throw 
op 06ff iget/jumbo     52c y field-ref  continue|throw 
op 07ff iget-wide/jumbo    52c y field-ref  continue|throw 
op 08ff iget-object/jumbo   52c y field-ref  continue|throw 
op 09ff iget-boolean/jumbo   52c y field-ref  continue|throw 
op 0aff iget-byte/jumbo    52c y field-ref  continue|throw 
op 0bff iget-char/jumbo    52c y field-ref  continue|throw 
op 0cff iget-short/jumbo   52c y field-ref  continue|throw 
op 0dff iput/jumbo     52c n field-ref  continue|throw 
op 0eff iput-wide/jumbo    52c n field-ref  continue|throw 
op 0fff iput-object/jumbo   52c n field-ref  continue|throw 
op 10ff iput-boolean/jumbo   52c n field-ref  continue|throw 
op 11ff iput-byte/jumbo    52c n field-ref  continue|throw 
op 12ff iput-char/jumbo    52c n field-ref  continue|throw 
op 13ff iput-short/jumbo   52c n field-ref  continue|throw 
op 14ff sget/jumbo     41c y field-ref  continue|throw 
op 15ff sget-wide/jumbo    41c y field-ref  continue|throw 
op 16ff sget-object/jumbo   41c y field-ref  continue|throw 
op 17ff sget-boolean/jumbo   41c y field-ref  continue|throw 
op 18ff sget-byte/jumbo    41c y field-ref  continue|throw 
op 19ff sget-char/jumbo    41c y field-ref  continue|throw 
op 1aff sget-short/jumbo   41c y field-ref  continue|throw 
op 1bff sput/jumbo     41c n field-ref  continue|throw 
op 1cff sput-wide/jumbo    41c n field-ref  continue|throw 
op 1dff sput-object/jumbo   41c n field-ref  continue|throw 
op 1eff sput-boolean/jumbo   41c n field-ref  continue|throw 
op 1fff sput-byte/jumbo    41c n field-ref  continue|throw 
op 20ff sput-char/jumbo    41c n field-ref  continue|throw 
op 21ff sput-short/jumbo   41c n field-ref  continue|throw 
op 22ff invoke-virtual/jumbo  5rc n method-ref continue|throw|invoke 
op 23ff invoke-super/jumbo   5rc n method-ref continue|throw|invoke 
op 24ff invoke-direct/jumbo   5rc n method-ref continue|throw|invoke 
op 25ff invoke-static/jumbo   5rc n method-ref continue|throw|invoke 
op 26ff invoke-interface/jumbo  5rc n method-ref continue|throw|invoke 
Các vấn đề liên quan