ThisIsLibra / AndroidProjectCreator

Convert an APK to an Android Studio Project using multiple open-source decompilers
https://maxkersten.nl/projects/androidprojectcreator/
GNU General Public License v3.0
369 stars 72 forks source link

NoSuchFileException on decompiling with fernflower #11

Closed vibin closed 4 years ago

vibin commented 4 years ago

Script fails with NoSuchFileException on decompiling with fernflower

JAR download link: https://drive.google.com/file/d/1ZzRccZ-h7Kt-Zl7hlB8nksx6TtJ8Nu_O/view?usp=sharing Java version: 1.8.0_102 Mac OS version: 10.14

Logs:

$ java -jar AndroidProjectCreator-1.3.jar -decompile fernflower uxcam.jar ./uxcam
[+]AndroidProjectCreator 1.3-stable [developed by Max 'Libra' Kersten <info@maxkersten.nl> or @LibraAnalysis on Twitter]

[+]Decompiling the APK to a temporary location (/Users/vibinreddy/Documents/android/library/temp/8e9bcf38-857b-4c63-be44-fc6c0d050475)
[+]Calling APKTool to decompile the AndroidManifest.xml and the application resources
[+]Decompling JAR with APKTOOL
I: Using Apktool 2.4.2-0143dc-SNAPSHOT on uxcam.jar
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...

[+]Decompilation finished
[+]Calling APKTool to obtain the SMALI code
[+]Decompling JAR with APKTOOL
I: Using Apktool 2.4.2-0143dc-SNAPSHOT on uxcam.jar
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...

[+]Decompilation finished
[+]Decompling JAR with DEX2JAR
dex2jar /Users/vibinreddy/Documents/android/library/temp/8e9bcf38-857b-4c63-be44-fc6c0d050475/apktool/classes.dex -> /Users/vibinreddy/Documents/android/library/temp/8e9bcf38-857b-4c63-be44-fc6c0d050475/output.jar
java.nio.file.NoSuchFileException: /Users/vibinreddy/Documents/android/library/temp/8e9bcf38-857b-4c63-be44-fc6c0d050475/apktool/classes.dex
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
    at java.nio.file.Files.newByteChannel(Files.java:361)
    at java.nio.file.Files.newByteChannel(Files.java:407)
    at java.nio.file.Files.readAllBytes(Files.java:3152)
    at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java:108)
    at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:290)
    at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:33)

[+]Decompilation finished
[+]Decompling JAR with FERNFLOWER
warn: missing '/Users/vibinreddy/Documents/android/library/temp/8e9bcf38-857b-4c63-be44-fc6c0d050475/output.jar', ignored
error: no sources given

[+]An error has occurred, therefore AndroidProjectCreator has shut down. The error message is given below.

Something went wrong with the I/O during the decompilation. Check the permissions of the output directory and try again.

I have looked into library/temp folder and it is empty.

ThisIsLibra commented 4 years ago

It seems to me that dex2jar cannot convert this classes.dex file for some reason. The reason fernflower fails, is because the JAR it it requested to decompile, does not exist.

The library/temp folder is empty due to the cleanup actions of APC upon crashing.

Please try to use APKTool and dex2jar manually to see if they crash at some point, as I do not think this is related to APC itself. Also check if the installation of all tools is successful.

vibin commented 4 years ago

Doesn't dex2jar expect a classes.dex? I think the issue is I gave a plain old JAR (instead of an APK/dex file) as input to APC. Is there a workaround?

ThisIsLibra commented 4 years ago

As its name suggests, dex2jar expects a classes.dex file. If you want to decompile a JAR, you can use one of the decompilers in the library folder and use that manually. In the Decompiler.java class in the source, you will find the default command line arguments that AndroidProjectCreator uses for the given programs. Note that AndroidProjectCreator is meant to decompiler an APK into a project, not a JAR.

Since this issue has been resolved, I'll close it.