Giter Site home page Giter Site logo

thexxturboxx / dex2jar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pxb1988/dex2jar

222.0 14.0 55.0 27.62 MB

Tools to work with android .dex and java .class files

License: Apache License 2.0

Java 71.47% Shell 0.12% Jasmin 0.75% GAP 2.23% Batchfile 0.01% ANTLR 0.54% Smali 24.89%
dex2jar dex android smali baksmali hacktoberfest bytecode dalvik

dex2jar's Introduction

dex2jar

Travis CI build status

This is Nico Mexis' fork of the dex2jar project which aims to fix most issues.

Fixed issues

  • Fixed many StringIndexOutOfBoundsExceptions relating to signatures
  • Fixed TypeTransformer related issues
  • Fixed many NullPointerExceptions and other crashes
  • Fixed grammar of error messages
  • Update libraries (especially ASM)
  • Library fat-jar can be used for other projects (Automatically produced by GitHub Actions)
  • Smali now outputs .param instead of the outdated .parameter syntax
  • Reformatted and cleaned up most of the code

Downloads

This fork has builds available in the following formats.
You can also only depend on a single module, if needed. The following sections include all the modules.

Maven

The builds are available on Maven Central.

<dependency>
    <groupId>de.femtopedia.dex2jar</groupId>
    <artifactId>dex2jar</artifactId>
    <version>VERSION</version>
</dependency>

Gradle

The builds are available on Maven Central.

implementation 'de.femtopedia.dex2jar:dex2jar:VERSION'

GitHub Releases

To download the latest builds, head to the Releases.

Note: The builds in Releases are automatically built by GitHub Actions.

Modules

Tools to work with android .dex and java .class files

  1. dex-reader/writer: Read/write the Dalvik Executable (.dex) file. It features a lightweight API similar with ASM .
  2. d2j-dex2jar: Convert .dex file to .class files (zipped as jar)
  3. smali/baksmali: Disassemble dex to smali files and assemble dex from smali files. Different implementation to smali/baksmali, same syntax, but we support escape in type desc "Lcom/dex2jar\t\u1234;"
  4. other tools: d2j-decrypt-string

Usage

  1. In the root directory run: ./gradlew distZip
  2. cd dex-tools/build/distributions
  3. Unzip the file dex-tools-2.4-SNAPSHOT.zip
  4. Run d2j-dex2jar.sh from the unzipped directory

Example usage:

sh d2j-dex2jar.sh -f ~/path/to/apk_to_decompile.apk

And the output file will be apk_to_decompile-dex2jar.jar.

Example Maven project:

See for example the infamous Bytecode Viewer.

Need help ?

Send an email to [email protected] or post on the issue tracker.

License

Apache 2.0

dex2jar's People

Contributors

ayyrickay avatar barriosnahuel avatar claui avatar col-e avatar geilige avatar js6pak avatar jschmid avatar kcmvp avatar marukohe avatar nick-botticelli avatar omeraydindev avatar paulo-raca avatar pxb1988 avatar sschuberth avatar thexxturboxx avatar twisterrob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dex2jar's Issues

UTF8 string too large on v53

ubuntu@fv48:~$ sh dex-tools-2.2-SNAPSHOT/d2j-dex2jar.sh pico.apk
dex2jar pico.apk -> ./pico-dex2jar.jar
GLITCH: 0004 L_a/a/_a;.<init>()V | not enough space for reading instruction
GLITCH: 000c L_/1;.<init>()V | not enough space for reading instruction
Applying workaround to method L_a/a/_a;#___a with original signature null by changing its types to java.lang.Object.
java.lang.IllegalArgumentException
        at org.objectweb.asm.ByteVector.putUTF8(ByteVector.java:213)
        at org.objectweb.asm.ClassWriter.newUTF8(ClassWriter.java:1092)
        at org.objectweb.asm.MethodWriter.<init>(MethodWriter.java:469)
        at org.objectweb.asm.ClassWriter.visitMethod(ClassWriter.java:793)
        at org.objectweb.asm.ClassVisitor.visitMethod(ClassVisitor.java:305)
        at org.objectweb.asm.commons.RemappingClassAdapter.visitMethod(RemappingClassAdapter.java:99)
        at org.objectweb.asm.ClassVisitor.visitMethod(ClassVisitor.java:305)
        at com.googlecode.d2j.dex.Dex2Asm.collectBasicMethodInfo(Dex2Asm.java:285)
        at com.googlecode.d2j.dex.Dex2Asm.convertMethod(Dex2Asm.java:611)
        at com.googlecode.d2j.dex.Dex2Asm.convertClass(Dex2Asm.java:469)
        at com.googlecode.d2j.dex.Dex2Asm.convertClass(Dex2Asm.java:380)
        at com.googlecode.d2j.dex.Dex2Asm.convertDex(Dex2Asm.java:508)
        at com.googlecode.d2j.dex.Dex2jar.doTranslate(Dex2jar.java:180)
        at com.googlecode.d2j.dex.Dex2jar.to(Dex2jar.java:280)
        at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java:112)
        at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:290)
        at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:33)

ubuntu@fv48:~$ java --version
openjdk 11.0.16.1 2022-08-12
OpenJDK Runtime Environment Temurin-11.0.16.1+1 (build 11.0.16.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.16.1+1 (build 11.0.16.1+1, mixed mode)

apk file: https://cdn.discordapp.com/attachments/757985854588190731/1014526587410075708/vr-_01.20.00.apk

i tried to convert dex -> java but it showed these errors^
it didn't work on pxb1988's dex2jar too.

i dont know about this as well, but is it possible to fix?

Method code too large exception

Please fix the Method code too large exception.

In this Issue comment (Which is in the main dex2jar repository) the comment explained that this exception is not necessary at all and then explained how to edit the byte code so that this exception doesn't happen anymore.

Please make it so that this exception doesn't happen by default.

Thank you.

Android projecr

Hello, I want to use this project in my Android project, what libraries are needed, if possible, give me their names.

got IndexOutOfBoundsException

v51

if i use openjava18. i got this error

#This file is generated by dex2jar
Please report this file to one of following link if possible (any one).
https://github.com/ThexXTURBOXx/dex2jar/issues
[email protected]

There are 1 fails.
2022-06-07 08:15:12 UTC
version: [dex-reader-null, dex-reader-api-null, dex-ir-null, d2j-smali-null, d2j-base-cmd-null, dex-tools-null, dex-translator-null]
cmdline: [--force, classes.dex]
env:
java.specification.version: 18
java.class.path: .:../dex-tools-2.1-SNAPSHOT/lib/ST4-4.3.1.jar:../dex-tools-2.1-SNAPSHOT/lib/antlr-3.5.2.jar:../dex-tools-2.1-SNAPSHOT/lib/antlr-runtime-3.5.2.jar:../dex-tools-2.1-SNAPSHOT/lib/antlr4-4.9.3.jar:../dex-tools-2.1-SNAPSHOT/lib/antlr4-runtime-4.9.3.jar:../dex-tools-2.1-SNAPSHOT/lib/asm-9.3.jar:../dex-tools-2.1-SNAPSHOT/lib/asm-analysis-9.3.jar:../dex-tools-2.1-SNAPSHOT/lib/asm-commons-9.3.jar:../dex-tools-2.1-SNAPSHOT/lib/asm-tree-9.3.jar:../dex-tools-2.1-SNAPSHOT/lib/asm-util-9.3.jar:../dex-tools-2.1-SNAPSHOT/lib/d2j-base-cmd-2.1-SNAPSHOT.jar:../dex-tools-2.1-SNAPSHOT/lib/d2j-jasmin-2.1-SNAPSHOT.jar:../dex-tools-2.1-SNAPSHOT/lib/d2j-smali-2.1-SNAPSHOT.jar:../dex-tools-2.1-SNAPSHOT/lib/d8-32.0.0.jar:../dex-tools-2.1-SNAPSHOT/lib/dex-ir-2.1-SNAPSHOT.jar:../dex-tools-2.1-SNAPSHOT/lib/dex-reader-2.1-SNAPSHOT.jar:../dex-tools-2.1-SNAPSHOT/lib/dex-reader-api-2.1-SNAPSHOT.jar:../dex-tools-2.1-SNAPSHOT/lib/dex-tools-2.1-SNAPSHOT.jar:../dex-tools-2.1-SNAPSHOT/lib/dex-translator-2.1-SNAPSHOT.jar:../dex-tools-2.1-SNAPSHOT/lib/dex-writer-2.1-SNAPSHOT.jar:../dex-tools-2.1-SNAPSHOT/lib/dx-30.0.3.jar:../dex-tools-2.1-SNAPSHOT/lib/icu4j-69.1.jar:../dex-tools-2.1-SNAPSHOT/lib/javax.json-1.0.4.jar:../dex-tools-2.1-SNAPSHOT/lib/org.abego.treelayout.core-1.0.3.jar
java.vm.vendor: Homebrew
java.vendor.url: https://github.com/Homebrew/homebrew-core/issues
java.vm.specification.version: 18
java.specification.vendor: Oracle Corporation
java.version.date: 2022-04-19
java.home: /usr/local/Cellar/openjdk/18.0.1/libexec/openjdk.jdk/Contents/Home
java.vm.compressedOopsMode: Zero based
java.vm.specification.vendor: Oracle Corporation
java.specification.name: Java Platform API Specification
java.runtime.version: 18.0.1+0
java.runtime.name: OpenJDK Runtime Environment
java.vm.name: OpenJDK 64-Bit Server VM
java.vendor.version: Homebrew
java.vendor.url.bug: https://github.com/Homebrew/homebrew-core/issues
java.io.tmpdir: /var/folders/2t/5kv5st7x3vqfhlvy8stqnkr40000gn/T/
java.version: 18.0.1
java.vm.specification.name: Java Virtual Machine Specification
java.library.path: /Users/nicko/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
java.vm.info: mixed mode, sharing
java.vendor: Homebrew
java.vm.version: 18.0.1+0
java.class.version: 62.0
java.lang.IndexOutOfBoundsException
at java.base/java.nio.Buffer.checkIndex(Buffer.java:746)
at java.base/java.nio.HeapByteBuffer.getInt(HeapByteBuffer.java:439)
at com.googlecode.d2j.reader.DexFileReader.getString(DexFileReader.java:1029)
at com.googlecode.d2j.reader.DexFileReader.getType(DexFileReader.java:1044)
at com.googlecode.d2j.reader.DexFileReader.accept(DexFileReader.java:716)
at com.googlecode.d2j.reader.DexFileReader.accept(DexFileReader.java:690)
at com.googlecode.d2j.dex.Dex2jar.doTranslate(Dex2jar.java:47)
at com.googlecode.d2j.dex.Dex2jar.to(Dex2jar.java:246)
at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java:103)
at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:297)
at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:16)

Using param `--optmize-synchronized` and `--reuse-reg` of `dex2jar` will consume more cpu/memory usage and time

d2j-dex2jar -- convert dex to jar
usage: d2j-dex2jar [options] <file0> [file1 ... fileN]
options:
...
 -os,--optmize-synchronized   optimize-synchronized
 -r,--reuse-reg               reuse register while generate java .class file
jvm param dex2jar param avg mem usage avg cpu usage
across 4 cores
25%=1 core
time spend visualvm screenshot
oracle jdk17
-Xms512m -Xmx8g
-os -r 3.5G 40% 38mins
graalvm jdk19
-Xms4g -Xmx5g
-os -r 3G 25%~35% 35mins
graalvm jdk19
-Xms3g -Xmx4g
-XX:+UseStringDeduplication
-XX:StringDeduplicationAgeThreshold=1
none 3G 25%~35% 32mins
graalvm jdk19
-Xms3g -Xmx4g
-XX:+UseStringDeduplication
-XX:StringDeduplicationAgeThreshold=1
-os 3.5G 25%~45% 40mins
graalvm jdk19
-Xms3g -Xmx4g
-XX:+UseStringDeduplication
-XX:StringDeduplicationAgeThreshold=1
-r 2.8G 25%~40% 36mins
graalvm jdk19
-Xms3g -Xmx4g
-XX:+UseStringDeduplication
-XX:StringDeduplicationAgeThreshold=1
-os -r 2.7G 40% 32mins

[question]Did you forget that you added a jar called ICU4J?

I found that your release is much bigger than pxb1988's!! I compared it to the jar. And I find that you added a jar to your release called ICU4J, which is 10M+ and takes up quite a lot of file volume.
Then I searched your entire dex2jar code project, and I couldn't find a single reference to "com.ibm." Am I to assume that this ICU4J is not actually referenced in your code?
If so, I recommend removing the ICU4J to reduce the size of the file considerably. Your downloads will definitely increase.
Of course, if you do refer to this jar, I feel that your reference to this jar is not very good. Except for ICU4J, all the others add up to about 3M, and this one jar takes up 10M. This is a serious question.

Support for two-way mapping, Asm2Dex

I'm currently looking into Android support on my project, Recaf (rewrite work where this would apply to), and am evaluating a number of potential paths. One such path would be the following:

  1. Read a DexFileNode from classes.dex
  2. Take each DexClassNode instances, store in a Map<String, DexClassNode>
  3. When a Android class is edited, lazily map it to a JVM class, edit that, then map back into DexClassNode
  4. Save changes to classes.dex by using DexFileWriter to take the Map<String, DexClassNode> and pack it back into classes.dex

One problem, I don't see anything to facilitate a Asm2Dex process. If need be I'd be willing to contribute work towards making it.

If you have any thoughts on how this process could be improved I'd love to hear 'em.

Trying to execute d2j-dex2jar.sh after giving executable permission , result in -bash: ./d2j-dex2jar.sh: /bin/sh^M: bad interpreter: No such file or directory

Hello @ThexXTURBOXx

We try to execute the following command in the mac OS after giving full permission results:
MacBook-Pro:$ ./d2j-dex2jar.sh -f -o /Users/Desktop/classes.jar /Users/Desktop/classes.dex
-bash: ./d2j-dex2jar.sh: /bin/sh^M: bad interpreter: No such file or directory

The above error is coming if we give the executable permission to the file "chmod +x d2j-dex2jar.sh". We like to know the reason for this problem.

Dex2jar erases inner class info

This was a painful one to track down, but this particular fork of dex2jar erases some of the inner class info when ran on a DEX file that was rewritten using dexlib2.

I have added a reproduction case in https://github.com/MikeAndrson/dex2jar/blob/main/main/src/main/java/Main.kt , it has a DEX file named classes_org.dex, and it:

  • Rewrites classes_org.dex to classes_dexlib2.dex using dexlib2,
  • Runs dex2jar on both classes_org.dex and classes_dexlib2.dex,
  • Textifies (with ASM) Main.class files produced by both DEX files,
  • Runs java-diff on those and prints the result.

The result is:
[DeleteDelta, position: 4, lines: [ // access flags 0x0, INNERCLASS Main$1 null null]]

image

Now this might seem trivial but it kinda messes with decompilers, which was a big problem for my project. So I decided to track it down and realized that this issue doesn't exist on the original dex2jar. So I checked the commits of this fork and found this one: 98196e0

image

I'm not sure why, but reverting the above change solves the issue.

You can try and see for yourself that the diff doesn't complain in my "revert" branch where I reverted that change: https://github.com/MikeAndrson/dex2jar/tree/revert


I'm not sure if the above change was necessary or not, but it does constitute a problem in my project 😅

Merging other peoples' work

@Aliucord @js6pak @Juby210 Would you allow me to merge some of your changes to this repo, such that some of your fixes are also included in BytecodeViewer or my builds on general?
That would be very nice from you :)

I know that the Apache license doesn't forbid me to just do it, but I still want to ask people before I do such stuff (I've had a very bad interaction with another developer once for basically the same reason).

Can't open Jar

Hello,
When I decompile it with the dex2jar.sh and try to open it in my java editor (Intellij IDEA) it doesn't open any ideas on how I can fix that?
Kind regards

Failing dependency from "sootup.java.bytecode" v.1.1.2

Hi @ThexXTURBOXx

I am working in a project in Scala that is using "SootUp" as a dependency.
In file build.sbt I am trying to download "org.soot-oss" % "sootup.callgraph" % "1.1.2"

image

and I am getting the error:

sbt.librarymanagement.ResolveException: Error downloading com.github.ThexXTURBOXx.dex2jar:dex-tools:v61

image

which is pointing this repository, so I am wondering if you can help me, sir

method in converted class has illegal modifiers: 0xA

dex2jar successfully converts the classes in my apk to a jar file.

However, while attempting to inspect those classes in a desktop application with Class.forName(name, false) (note the initialize = false arg), I see this error:

error: unable to process AboutBottomSheet.kt: Method $jacocoInit in class androidx/lifecycle/HasDefaultViewModelProviderFactory has illegal modifiers: 0xA

After some investigating, I'm guessing this corresponds to a default modifier in the HasDefaultViewModelProviderFactory interface (defined by Android):

default CreationExtras getDefaultViewModelCreationExtras() {
    return CreationExtras.Empty.INSTANCE;
}

This modifier was introduced in Java 8 (52), but the Android classes are for Java 6 (50).

So I believe the error results from a newer modifier in an older class version where it was not supported.

Can someone with greater knowledge confirm this suspicion, or comment on what else might be going on?

Incidentally, I tried converting that class to level 52 with d2j-class-version-switch.sh, but the problem remains.

OutOfMemoryError

dex2jar ../com.ss.android.ugc.aweme.lite.apk -> .\com.ss.android.ugc.aweme.lite-dex2jar.jar
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Unknown Source)
at java.lang.String.(Unknown Source)
at java.lang.StringBuilder.toString(Unknown Source)
at com.googlecode.d2j.util.Mutf8.decode(Mutf8.java:42)
at com.googlecode.d2j.reader.DexFileReader.getString(DexFileReader.java:1034)
at com.googlecode.d2j.reader.DexFileReader.getType(DexFileReader.java:1044)
at com.googlecode.d2j.reader.DexFileReader.getMethod(DexFileReader.java:1022)
at com.googlecode.d2j.reader.DexFileReader.acceptInsn(DexFileReader.java:1728)
at com.googlecode.d2j.reader.DexFileReader.acceptCode(DexFileReader.java:1489)
at com.googlecode.d2j.reader.DexFileReader.acceptMethod(DexFileReader.java:1142)
at com.googlecode.d2j.reader.DexFileReader.acceptClass(DexFileReader.java:918)
at com.googlecode.d2j.reader.DexFileReader.accept(DexFileReader.java:725)
at com.googlecode.d2j.reader.MultiDexFileReader.accept(MultiDexFileReader.java:122)
at com.googlecode.d2j.reader.MultiDexFileReader.accept(MultiDexFileReader.java:115)
at com.googlecode.d2j.dex.Dex2jar.doTranslate(Dex2jar.java:48)
at com.googlecode.d2j.dex.Dex2jar.to(Dex2jar.java:235)
at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java:103)
at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:297)
at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:16)

Invalid or corrupt jarfile

java -jar d2j-jar2dex.sh classes_patched.jar
Error: Invalid or corrupt jarfile d2j-jar2dex.sh

JAR file is the same one dex2jar produced. How come?

Regarding kotlin and Java 8 support

Hello,

Is there any plan to support Kotlin features here. With current code, when we try to use dex to jar , most of the files are getting skipped and in the final jar kotlin classes are missed out or compiling incorrectly.

Regression at dex2jar v65+ lambda adapter

The commit 1096eeb introduces a bug regarding the signature of lambda methods.
How to reproduce:

Consider this code as the content of a file named Example.kt:

package example

fun main(args : Array<String>) {
    val data = runCatching { throw Exception() }.getOrElse { "bruh" }
    println(data)
}

Compile it to a .dex file, using d8:

$ kotlinc Example.kt -d example.jar
$ d8 example.jar 2>/dev/null

Using dex2jar-v64, the compiled dex can be converted back to a executable .jar file just fine:

$ ./dex-tools-v64/d2j-dex2jar.sh --output ok-result-v64.jar classes.dex
dex2jar classes.dex -> ok-result-v64.jar

$ kotlin -cp ok-result-v64.jar example.ExampleKt
bruh

But when using dex2jar-v65+, executing the generated jar file throws an NoSuchMethodError error:

$ ./dex-tools-v65/d2j-dex2jar.sh --output error-result-v65.jar classes.dex
dex2jar classes.dex -> error-result-v65.jar

$ kotlin -cp error-result-v66.jar example.ExampleKt
Exception in thread "main" java.lang.NoSuchMethodError: 'java.lang.Object kotlin.Result.constructor_impl(java.lang.Object)'
        at example.ExampleKt.main(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.jetbrains.kotlin.runner.AbstractRunner.run(runners.kt:70)
        at org.jetbrains.kotlin.runner.Main.run(Main.kt:194)

I don't know if this only affects Kotlin lambdas, or if Java lambdas are also affected.

Java 17.0.8 / Kotlin 1.9.20

Issue with dex2jar: Index -1 out of bounds for length 0

dex2jar ../app.apk -> ./app-dex2jar.jar
ASM fail to generate .class file: iko/lxf
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 0
	at org.objectweb.asm.Frame.getConcreteOutputType(Frame.java:1140)
	at org.objectweb.asm.Frame.merge(Frame.java:1185)
	at org.objectweb.asm.CurrentFrame.execute(CurrentFrame.java:53)
	at org.objectweb.asm.MethodWriter.visitVarInsn(MethodWriter.java:927)
	at org.objectweb.asm.ClassReader.readCode(ClassReader.java:2409)
	at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1514)
	at org.objectweb.asm.ClassReader.accept(ClassReader.java:744)
	at org.objectweb.asm.ClassWriter.replaceAsmInstructions(ClassWriter.java:777)
	at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:740)
	at com.googlecode.d2j.dex.Dex2jar$1$1.visitEnd(Dex2jar.java:71)
	at com.googlecode.d2j.dex.Dex2Asm.convertClass(Dex2Asm.java:555)
	at com.googlecode.d2j.dex.Dex2Asm.convertClass(Dex2Asm.java:449)
	at com.googlecode.d2j.dex.Dex2Asm.convertDex(Dex2Asm.java:614)
	at com.googlecode.d2j.dex.Dex2jar.doTranslate(Dex2jar.java:153)
	at com.googlecode.d2j.dex.Dex2jar.to(Dex2jar.java:253)
	at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java:103)
	at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:297)
	at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:16)
ASM fail to generate .class file: iko/oxf
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 0
	at org.objectweb.asm.Frame.getConcreteOutputType(Frame.java:1140)
	at org.objectweb.asm.Frame.merge(Frame.java:1185)
	at org.objectweb.asm.CurrentFrame.execute(CurrentFrame.java:53)
	at org.objectweb.asm.MethodWriter.visitVarInsn(MethodWriter.java:927)
	at org.objectweb.asm.ClassReader.readCode(ClassReader.java:2409)
	at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1514)
	at org.objectweb.asm.ClassReader.accept(ClassReader.java:744)
	at org.objectweb.asm.ClassWriter.replaceAsmInstructions(ClassWriter.java:777)
	at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:740)
	at com.googlecode.d2j.dex.Dex2jar$1$1.visitEnd(Dex2jar.java:71)
	at com.googlecode.d2j.dex.Dex2Asm.convertClass(Dex2Asm.java:555)
	at com.googlecode.d2j.dex.Dex2Asm.convertClass(Dex2Asm.java:449)
	at com.googlecode.d2j.dex.Dex2Asm.convertDex(Dex2Asm.java:614)
	at com.googlecode.d2j.dex.Dex2jar.doTranslate(Dex2jar.java:153)
	at com.googlecode.d2j.dex.Dex2jar.to(Dex2jar.java:253)
	at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java:103)
	at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:297)
	at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:16)
Detail Error Information in File ./app-error.zip

app-error.zip

will send apk to email

Using latest Dex2Jar : Seeing this failure " Failed resolution of: Lres/Hex "

Hello @ThexXTURBOXx

When we try to use https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp/4.9.3 in the apk. It results in following error.

Process: com.sampleapp, PID: 13211
java.lang.NoClassDefFoundError: Failed resolution of: Lres/Hex;
at okhttp3.internal.http2.Huffman.$d2j$hex$c61541e3$decode_I(Unknown Source:16)
at okhttp3.internal.http2.Huffman.(Unknown Source:17)
at okhttp3.internal.http2.Hpack$Writer.writeByteString(Unknown Source:11)
at okhttp3.internal.http2.Hpack$Writer.writeHeaders(Unknown Source:264)
at okhttp3.internal.http2.Http2Writer.headers(Unknown Source:12)
at okhttp3.internal.http2.Http2Connection.newStream(Unknown Source:82)
at okhttp3.internal.http2.Http2Connection.newStream(Unknown Source:6)
at okhttp3.internal.http2.Http2ExchangeCodec.writeRequestHeaders(Unknown Source:25)
at okhttp3.internal.connection.Exchange.writeRequestHeaders(Unknown Source:16)
at okhttp3.internal.http.CallServerInterceptor.intercept(Unknown Source:29)
at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80)
at okhttp3.internal.connection.ConnectInterceptor.intercept(Unknown Source:32)
at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80)
at okhttp3.internal.cache.CacheInterceptor.intercept(Unknown Source:192)
at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80)
at okhttp3.internal.http.BridgeInterceptor.intercept(Unknown Source:171)
at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(Unknown Source:37)
at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(Unknown Source:119)
at okhttp3.internal.connection.RealCall.execute(Unknown Source:27)

How we are calling the OkHttpClient from code: The problem is with 4.x.x http library

private static final String URL_STRING = "https://www.google.com/";
private void okHttpLib()
{
try {
new Thread(new Runnable()
{
@OverRide
public void run()
{
try {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(URL_STRING)
.build();
Response response = client.newCall(request).execute();
Log.i(LOG_TAG, "OK HTTP, " + URL_STRING + ", status code: " + response.code());
response.body().string();
}
catch (Exception e) {
Log.e(LOG_TAG, "Exception while making okhttp call");
}
}
}).start();
}
catch (Exception e) {
Log.e(LOG_TAG, "Exception", e);
}
}

Can you please check this issue?

Come and have a look

At file dex-translator/src/main/java/com/googlecode/d2j/converter/J2IRConverter.java
line 562:
case T_DOUBLE:
return b(1, Exprs.nNewArray("D", local));
case T_LONG:
return b(1, Exprs.nNewArray("D", local));

WARN: Ignored invalid inner-class name, treat as anonymous inner class

dex2jar C:\Users\RUSSIAVK\Desktop\apk\alipay_wap_main.apk -> .\alipay_wap_main-dex2jar.jar
WARN: Ignored invalid inner-class name, treat as anonymous inner class. (1AfterExitAppRunnable)
WARN: Ignored invalid inner-class name, treat as anonymous inner class. (1CompleteRunnable)
WARN: Ignored invalid inner-class name, treat as anonymous inner class. (1FinishAppRunnable)
WARN: Ignored invalid inner-class name, treat as anonymous inner class. (1WaitActivityDestroyRunnable)
WARN: Ignored invalid inner-class name, treat as anonymous inner class. (1AfterExitAppRunnable)
WARN: Ignored invalid inner-class name, treat as anonymous inner class. (1FinishAppRunnable)
WARN: Ignored invalid inner-class name, treat as anonymous inner class. (1WaitActivityDestroyRunnable)

APK FILE :https://t.alipayobjects.com/L1/71/100/and/alipay_wap_main.apk

[BUG] The jar has problems after decompilation.

Decompiled an apk to get a jar. After running, it was found to crash all the time. Finally, it was found that the decompiled app jar error.
You can see "-I" changed to "_I". It's not right. Below show:
image

The origin code:
image

I know, we can change smali file to fix. But let me just mention that. It would be nice to have a tool that can fix that.

Error: jar2dex This is symptomatic of .class transformation tools that ignore local variable information.

I'm trying to use jar2dex having the following errors:

jar2dex tmp/monitored_app-converter.apk.jar -> tmp/classes.dex
call com.android.dx.command.Main.main[--dex, --no-strict, --output=/Users/gabrielmartins/Desktop/UnB/TCC/RuntimeVerification/rv-android/beta/cli/tmp/classes.dex, --min-sdk-version=13, /Users/gabrielmartins/Desktop/UnB/TCC/RuntimeVerification/rv-android/beta/cli/tmp/monitored_app-converter.apk.jar]
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.String[] using a local variable of type androidx.activity.result.contract.ActivityResultContract. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type int[] using a local variable of type android.content.Intent. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.Object[] using a local variable of type java.lang.String. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.reflect.Constructor using a local variable of type java.lang.Class[]. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.io.FileOutputStream using a local variable of type java.lang.Object[]. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type int[] using a local variable of type android.content.Context. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type android.graphics.drawable.Drawable[] using a local variable of type android.graphics.drawable.Drawable. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type android.graphics.drawable.Drawable[] using a local variable of type android.graphics.drawable.Drawable. This is symptomatic of .class transformation tools that ignore local variable information.
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.String[] using a local variable of type android.app.SearchableInfo. This is symptomatic of .class transformation tools that ignore local variable information.

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
	at com.android.dx.command.dexer.Main.processAllFiles(Main.java:614)
	at com.android.dx.command.dexer.Main.runMonoDex(Main.java:310)
	at com.android.dx.command.dexer.Main.runDx(Main.java:288)
	at com.android.dx.command.dexer.Main.main(Main.java:244)
	at com.android.dx.command.Main.main(Main.java:95)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.googlecode.dex2jar.tools.Jar2Dex.doCommandLine(Jar2Dex.java:84)
	at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:297)
	at com.googlecode.dex2jar.tools.Jar2Dex.main(Jar2Dex.java:14)
Caused by: java.lang.InterruptedException: Too many errors
	at com.android.dx.command.dexer.Main.processAllFiles(Main.java:606)
	... 11 more

What I'm doing is using the rv-android tool to instrument an android app apk and check when the app accesses some android API.

When converting the Jar to Dex I'm having these errors.
Do you know what it could be and how to fix it?

What is the best Method to edit the code of an apk?

I created the jar and can read it with jd-gui but I cannot edit it.

I don't know what to do with the jar now.
I would like to be able to edit the code. I don't know Java bytecode but would be open to learn it if necessary.
Does anybody have any tips on getting started modifying the code of android apps?

I don't know where else to post it.

I tried converting it to jasmin but it fails with this error:

Exception in thread "main" java.lang.NoSuchMethodError: 'void org.objectweb.asm.util.Printer.appendString(java.lang.StringBuilder, java.lang.String)' at com.googlecode.d2j.jasmin.JasminDumper.print(JasminDumper.java:618) at com.googlecode.d2j.jasmin.JasminDumper$1.visitLdcInsn(JasminDumper.java:410) at org.objectweb.asm.tree.LdcInsnNode.accept(LdcInsnNode.java:71) at com.googlecode.d2j.jasmin.JasminDumper.dump(JasminDumper.java:296) at com.googlecode.d2j.jasmin.Jar2JasminCmd.disassemble1(Jar2JasminCmd.java:108) at com.googlecode.d2j.jasmin.Jar2JasminCmd.access$000(Jar2JasminCmd.java:21) at com.googlecode.d2j.jasmin.Jar2JasminCmd$1.visitFile(Jar2JasminCmd.java:92) at com.googlecode.d2j.jasmin.Jar2JasminCmd$1.visitFile(Jar2JasminCmd.java:88) at java.base/java.nio.file.Files.walkFileTree(Files.java:2811) at java.base/java.nio.file.Files.walkFileTree(Files.java:2882) at com.googlecode.d2j.jasmin.Jar2JasminCmd.travelFileTree(Jar2JasminCmd.java:88) at com.googlecode.d2j.jasmin.Jar2JasminCmd.disassemble0(Jar2JasminCmd.java:82) at com.googlecode.d2j.jasmin.Jar2JasminCmd.doCommandLine(Jar2JasminCmd.java:67) at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:297) at com.googlecode.d2j.jasmin.Jar2JasminCmd.main(Jar2JasminCmd.java:37)

Is this even a good approach to editing the code?

I hope somebody will be able to help me

dex2jar only includes class files in the converted jar

I have this apk: tachiyomi-zh.copymanga-v1.3.48.zip

The contents are:

$ unzip tachiyomi-zh.copymanga-v1.3.48.apk 
Archive:  tachiyomi-zh.copymanga-v1.3.48.apk
  inflating: META-INF/com/android/build/gradle/app-metadata.properties  
  inflating: classes.dex             
  inflating: kotlin-tooling-metadata.json  
  inflating: simp.txt                
  inflating: simplified.txt          
  inflating: AndroidManifest.xml     
 extracting: res/CG.png              
 extracting: res/D2.png              
 extracting: res/SD.png              
 extracting: res/jy.png              
 extracting: res/u3.png              
 extracting: resources.arsc          
  inflating: META-INF/CERT.SF        
  inflating: META-INF/CERT.RSA       
  inflating: META-INF/MANIFEST.MF 

Part of the code inside the apk is using this library: https://github.com/luhuiguo/chinese-utils/blob/master/src/main/java/com/luhuiguo/chinese/Converter.java#L49 and the stacktrace is available at Suwayomi/Suwayomi-Server#512 (comment)

That library requires to load resource file /simp.txt or /simplified.txt but these are not included in the converted jar.

We are converting dex2jar via this function: https://github.com/Suwayomi/Tachidesk-Server/blob/master/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/PackageTools.kt#L53

Is there something we can do to make dex2jar include non-class files as well?

[advice] use SemVer, it's more standard

From what I've observed, you like to use a generic version to manage releases, which creates a problem. It is this version of "vNum" that is not loved by programmers.
As programmers, we are more familiar with using the SemVer. Isn't that right?
So, I feel that release can also use this semantic version, with just a few minor changes. For example, v73 -> 0.7.3. It's simple, and it looks pretty standard.

Make output deterministic

It would be nice if the generated JAR for a given input could be deterministic. Not sure if there are more hoops to go through, but my main complaint is that certain methods' auto-generated names seem to be changing each time you generate, like this one: $d2j$hex$c51fa2bb$decode_J

If you need a reproduction case, take any YouTube APK and search the given output JAR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.