Java file generation from apk (Bytecode Viewer expression)

The accuracy of dex2jar was not good enough, so I will introduce the one with good accuracy.

Bytecode Viewer https://bytecodeviewer.com/

Instead of dex2jar. GUI operation. It's kind of like JD-GUI. It's usually convenient. You can decompile apk, dex, jar, zip and class. After decompiling, you can view it with your favorite decompiler. You can save the class from apk, or output java decompiled with a decompiler. However, the output to java is unstable. If you download this and start it, there is a place where "Drag class / jar / APK / DEX here" is written, so drag and drop .apk there. Then, when the process is finished, the finished product will come out, so save it as a zip from File-> Save As Zip.

Procyon https://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler

It's a decompiler with a built-in Bytecode Viewer. I think it's stable.

To decompile, change the extension of the zip output by Bytecode Viewer to jar.

java -jar procyon-decompiler-x.x.xx.jar -jar myJar.jar -o out

Change the Procyon jar file name to suit yours. myJar.jar is the file name output by Bytecode Viewer. And do this. out is the output destination directory. This is where the java file goes. There is no need to make it in advance.

Decompiler comparison

I'm usually a Fernflower sect, but I looked at the source code I made (because the IDE I usually use is Intellij IDEA) and compared it, but there are two points that I thought were better than Fernflower.

--Simplified how to write the source code --Names that make it easy to understand variable names that are not written in class

The accuracy is almost the same as Fernflower, it is written in Fernflower but not in Procyon, and vice versa. I think the accuracy is quite high.

for statement comparison Fernflower

ServiceApiEnvironment[] var1 = values();
int var2 = var1.length;

for(int var3 = 0; var3 < var2; ++var3) {
  ServiceApiEnvironment var4 = var1[var3];
  if (var4.equals(var0)) {
    return var4;
  }
}

Procyon

for (final ServiceApiEnvironment serviceApiEnvironment : values()) {
  if (serviceApiEnvironment.equals(s)) {
    return serviceApiEnvironment;
  }
}

Procyon is overwhelmingly easier to see, isn't it? So I think Procyon is the best. Fernflower spit out a lot of errors, but Procyon only once.

Recommended Posts

Java file generation from apk (Bytecode Viewer expression)
Java starting from beginner, class declaration / object generation
Java permutation generation
java file creation
[Java] Lambda expression
Java lambda expression
How to jump from Eclipse Java to a SQL file
[Java] How to extract the file name from the path