-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] temp file not being deleted when building #2739
Comments
Thanks for the research, I'll use this research and dig around in a bit and see what I can find. |
Thanks, found em. PR is up. |
I just tested with the apktool .jar file built from the GitHub Action (the build artifact .jar named The APKTOOL.tmp file that isn't being removed is opened several times using Win32 API CreateFile(), which it seems is used for reading, writing, getting attributes from a file and even for deleting. The last CreateFile() call that should remove the file gets a Sharing Violation, so my guess is that some object still has a handle on the file. And there's a CreateFile call that isn't matched with a CloseFile call that may be the reason. From trying to match the calls to the code in
(I guess the GC at some point collects the object and closes the file, but the |
:( Thanks will reopen. |
My guess is that something like that would help:
I'm not quite sure if there's another way to do that in Java. |
Okay, next PR has to be perfect. I've done a looped build/decode of 10 applications 20 times and I have no files in /tmp. Additionally, scripted the actual building of Apktool 20 times and no /tmp files. |
I'd like to test the PR, but unfortunately the GitHub action doesn't provide a built apktool.jar, only when merged to |
Works! I tested with |
Information
apktool -version
) - 2.6.0Steps to Reproduce
apktool b -o out extractedFolder
APKTOOL{longnumber}.tmp
files are created, and one of the is removed again. The other stays there.Note that this only occurs when (re-)building, not when decompiling an .apk. After digging a bit in the source, I suspect the following lines in
buildManifest()
to be the problem:Apktool/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java
Lines 548 to 549 in 9bdf385
Here, the temporary file is being created and then deleted again (I guess to get the temp filename). Then the filename is used in a call to
aaptPackage()
, but afterwards it isn't deleted.Note that
buildResourcesFull()
also creates a temp filename, but deletes the created file again in line 512, and that's the difference tobuildManifest()
:Apktool/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java
Line 512 in 9bdf385
The text was updated successfully, but these errors were encountered: