yahia
yahia

Reputation: 11

Apktool Error Caused by: org.jf.util.ExceptionWithContext: Error while writing instruction at code offset 0x2

Hello guys i Decompiled an apk using apktool in linux and i've done some changes not much actually and i'm very sure there's nothing wrong in my files but when i'm recompiling the apk again i get an error so i tried to do it through windows Easy apk tool but i'm still having the sane error is there's anyone knows how to solve that? here's the logs

11/26/2023 12:48:17 AM

java version "1.8.0_391"
Java(TM) SE Runtime Environment (build 1.8.0_391-b13)
Java HotSpot(TM) Client VM (build 25.391-b13, mixed mode, sharing)
---------------------------

Compiling APK file... (Press ESC to cancel) Command: java.exe -jar "C:\Users\Yahia\Downloads\APK Easy Tool v1.60 Portable\Apktool\apktool_2.6.1.jar" b -f --use-aapt2 -o "C:\Users\Yahia\Downloads\APK Easy Tool v1.60 Portable\2-Recompiled APKs\original.apk" "C:\Users\Yahia\Desktop\appneedscombaining\root\original"

I: Using Apktool 2.6.1 I: Smaling smali folder into classes.dex... Exception in thread "main" org.jf.util.ExceptionWithContext: Exception occurred while writing code_item for method Landroidx/annotation/InspectableProperty$ValueType;->values()[Landroidx/annotation/InspectableProperty$ValueType;
    at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:1047)
    at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:346)
    at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:301)
    at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:58)
    at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:37)
    at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:430)
    at brut.androlib.Androlib.buildSources(Androlib.java:361)
    at brut.androlib.Androlib.build(Androlib.java:313)
    at brut.androlib.Androlib.build(Androlib.java:280)
    at brut.apktool.Main.cmdBuild(Main.java:255)
    at brut.apktool.Main.main(Main.java:82)
Caused by: org.jf.util.ExceptionWithContext: Error while writing instruction at code offset 0x2
    at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1320)
    at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:1043)
    10 more
Caused by: org.jf.util.ExceptionWithContext: Unsigned short value out of range: 65554
    at org.jf.dexlib2.writer.DexDataWriter.writeUshort(DexDataWriter.java:116)
    at org.jf.dexlib2.writer.InstructionWriter.write(InstructionWriter.java:356)
    at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1280)
    11 more

Compile failed. Please read the log

Decompiling an app then Recompiling it

Upvotes: 0

Views: 619

Answers (1)

Connor Tumbleson
Connor Tumbleson

Reputation: 3330

You've exceeded the amount of methods allowed per dex file. You can tell from this line.

Caused by: org.jf.util.ExceptionWithContext: Unsigned short value out of range: 65554

As the max methods per dex is unsigned short of 65,535. In some circumstances as a by-product of disassembly baksmali may generate more methods than it had prior. However, due to this size I believe you edited/added more methods and exceeded the size available.

Upvotes: 1

Related Questions