Getting the below exception when writing the dex file with dexlib2. The error occurs even when rewriting the dex file without making any changes to the dex file. The dex file is of version 039. Tried with latest version of dexlib2 (2.5.2)
Exception in thread "pool-1-thread-1" org.jf.util.ExceptionWithContext: Exception occurred while writing code_item for method Lcom/google/protobuf/g0$f$e$a;->d(Lcom/google/protobuf/g0;)I
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 org.jf.dexlib2.writer.pool.DexPool.writeTo(DexPool.java:98)
at org.jf.dexlib2.DexFileFactory.writeDexFile(DexFileFactory.java:292)
at com.example.dexter.DexFileOps.writeToDexFile(DexFileOps.java:60)
at com.example.dexter.Dexter.rewriteReferences(Dexter.java:371)
at com.example.dexter.Dexter.readAndWriteDex(Dexter.java:404)
at com.example.dexter.Dexter$1.run(Dexter.java:294)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
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)
... 11 more
Caused by: org.jf.util.ExceptionWithContext: Item not found.: (Lcom/google/protobuf/g0;)Ljava/lang/Integer;
at org.jf.dexlib2.writer.pool.BaseIndexPool.getItemIndex(BaseIndexPool.java:54)
at org.jf.dexlib2.writer.InstructionWriter.getReferenceIndex(InstructionWriter.java:561)
at org.jf.dexlib2.writer.InstructionWriter.getReference2Index(InstructionWriter.java:546)
at org.jf.dexlib2.writer.InstructionWriter.write(InstructionWriter.java:429)
at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1298)
... 12 more
I suspect this may be fixed by some of the recently merged PRs. Can you try the current tip-of-tree dexlib2 and see if it works now? Feel free to reopen if it's still not working for you.
Getting the below exception when writing the dex file with
dexlib2
. The error occurs even when rewriting the dex file without making any changes to the dex file. The dex file is of version 039. Tried with latest version of dexlib2 (2.5.2)