Apktool
                                
                                
                                
                                    Apktool copied to clipboard
                            
                            
                            
                        [BUG] Path quotes are broken, kinda?
Information
- Apktool Version (
apktool -version) - 2.6.1 - Operating System (Mac, Linux, Windows) - Windows
 
Stacktrace/Logcat
>apktool
'""C:' is not recognized as an internal or external command,
operable program or batch file.
Steps to Reproduce
- set 
%JAVA_HOME%to a path with a space, which needs quotes to work with most software. E.g.:"C:/Program Files/Java/jdk-15.0.2" - comment out 
@echo off(to show actual commands) - Run 
apktool. apktoolcrashes when the batch file tries to invoke the jar with:
""C:/Program Files/Java/jdk-15.0.2"\bin\java.exe" -jar -Duser.language=en -Dfile.encoding=UTF8 "C:\apktool\apktool.jar"
'""C:' is not recognized as an internal or external command,
operable program or batch file.
Questions to ask before submission
- Have you tried 
apktool d,apktool bwithout changing anything? N/A, but yes. - If you are trying to install a modified apk, did you resign it? N/A
 - Are you using the latest apktool version? yes
 
Fix for my system
By adding quotes around %java_exe% - "%java_exe%", it invokes the jar correctly. It produces this monstrosity of a command line:
"""C:/Program Files/Java/jdk-15.0.2"\bin\java.exe"" -jar -Duser.language=en -Dfile.encoding=UTF8 "C:\apktool\apktool.jar"
and that works! There's no way that's the right solution. But string manipulation in batch scripts is painful & cruel, so I'm not gonna try writing a proper patch.
...I'm still hoping that filing this bug report might help someone!
Not sure of any solution myself, but if thats what Gradle does - https://github.com/iBotPeaches/Apktool/blob/master/gradlew.bat#L74
That works for me. If you'd like to PR that - I'd accept it. Otherwise I'll get to it in a day or so.
as long you have at least one result in where java.exe (errorlevel will return 0), I.E. it exists in PATH, you are perfectly fine just to run call java -jar ..., you don't need to actually build the target path to the java execute, that's an unneeded overkill mess.
don't use that batch file,
write your own or use something like that:
https://github.com/eladkarako/android/blob/master/bin/apktool/apktool.cmd
I think batch scripts are an abomination, so I don't generally submit PRs about them :)
I think batch scripts are an abomination
you are more than welcome to use NodeJS js
with child_processes and spawn, to skip the shell middleman
and launch your application directly with whatever arguments you want.
will work the same for any OS.