bytecode-viewer icon indicating copy to clipboard operation
bytecode-viewer copied to clipboard

Can't open an apk if the current directory is not in the same filesystem as the home directory

Open tbodt opened this issue 4 years ago • 4 comments

According to strace, dex2jar outputs into a file in the current directory, which is then moved into ~/.Bytecode-Viewer, but the move fails if the current directory is not on the same filesystem. This failure is silently ignored and results in a FileNotFoundException.

Log:

https://the.bytecode.club - Created by @Konloch - Bytecode Viewer 2.9.22, Fat-Jar: true
Start up took 3 seconds
I: Using Apktool 2.3.0 on calvliYOzSFHBpmjErwIgSPSSLBpYZQw.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/tbodt/.Bytecode-Viewer/bcv_temp/ocdLychdqhWT/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
dex2jar /home/tbodt/.Bytecode-Viewer/bcv_temp/calvliYOzSFHBpmjErwIgSPSSLBpYZQw.apk -> ./calvliYOzSFHBpmjErwIgSPSSLBpYZQw-dex2jar.jar
java.io.FileNotFoundException: /home/tbodt/.Bytecode-Viewer/bcv_temp/zBTpKnEbpgWhomIeHFodTVblq.jar (No such file or directory)
        at java.io.FileInputStream.open0(Native Method)
        at java.io.FileInputStream.open(FileInputStream.java:195)
        at java.io.FileInputStream.<init>(FileInputStream.java:138)
        at the.bytecode.club.bytecodeviewer.util.JarUtils.loadClasses(JarUtils.java:168)
        at the.bytecode.club.bytecodeviewer.BytecodeViewer$8.run(BytecodeViewer.java:961)

tbodt avatar Feb 21 '20 00:02 tbodt

I had a similar issue. I attached strace and found that there is an issue when the application tries to move the file from local directory ./ (where the application is executed) to /home/<username>/.Bytecode-Viewer/bcv_temp/.

strace output snippet:

...
9781 rename("xxxxxxxxx-dex2jar.jar", "/home/<username>/.Bytecode-Viewer/bcv_temp/xxxxxxxxx.jar" <unfinished ...>
19696 <... gettid resumed>)             = 19696
19781 <... rename resumed>)             = -1 EXDEV (Invalid cross-device link)
...

Proposed Solutions: If you want a quick and easy solution, move the main application into a folder within the main OS that supports the functionality (probably support of linking).

Another solution would be to change the code and have the temporary file created in /home/<username>/.Bytecode-Viewer/bcv_temp/ or /tmp/ instead of ./.

kxynos avatar May 28 '20 10:05 kxynos

anything on this? still happens in 2022 on every file

Silur avatar May 22 '22 10:05 Silur

anything on this? still happens in 2022 on every file

Hello, could you include your operating system and JRE/JDK version? I will look into this for you

Konloch avatar May 22 '22 10:05 Konloch

ArchLinux 5.17.4-arch1-1 x86_64, tried with java 8 and 9 using archlinux-java

Silur avatar May 23 '22 12:05 Silur