LuigiVampa92 / xapk-to-apk

A simple standalone python script that converts .xapk file into a normal universal .apk file
https://github.com/LuigiVampa92/xapk-to-apk
MIT License
68 stars 17 forks source link

[WinError 2] The system cannot find the file specified #7

Open pirateorno opened 1 month ago

pirateorno commented 1 month ago

C:\NeWindows\Scripts\pythin\xapk-to-apk-development>python xapktoapk.py brawl.xapk [] start [] unpacking xapk [] xapk file unpacked. 21 parts discovered [] unpacking 1 of 21 Traceback (most recent call last): File "C:\NeWindows\Scripts\pythin\xapk-to-apk-development\xapktoapk.py", line 617, in main() File "C:\NeWindows\Scripts\pythin\xapk-to-apk-development\xapktoapk.py", line 588, in main unpack_apk(path_dir_tmp, apk_file, index + 1, unpack_number_total) File "C:\NeWindows\Scripts\pythin\xapk-to-apk-development\xapktoapk.py", line 314, in unpack_apk rc = execute_command_subprocess(['apktool', 'd', '-s', apk_file]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\NeWindows\Scripts\pythin\xapk-to-apk-development\xapktoapk.py", line 77, in execute_command_subprocess rc = call(command_tokens_list, stdout=DEVNULL, stderr=STDOUT) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 389, in call with Popen(*popenargs, **kwargs) as p: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1538, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [WinError 2] The system cannot find the file specified

but i have file in C:\NeWindows\Scripts\pythin\xapk-to-apk-development.xapktoapk\com.supercell.brawlstars.apk

Evyatar108 commented 1 month ago

same issue here

[] start [] unpacking xapk [] xapk file unpacked. 4 parts discovered [] unpacking 1 of 4 Traceback (most recent call last): File "D:\Android\Repos\xapk-to-apk\xapktoapk.py", line 617, in main() File "D:\Android\Repos\xapk-to-apk\xapktoapk.py", line 588, in main unpack_apk(path_dir_tmp, apk_file, index + 1, unpack_number_total) File "D:\Android\Repos\xapk-to-apk\xapktoapk.py", line 314, in unpack_apk rc = execute_command_subprocess(['apktool', 'd', '-s', apk_file]) File "D:\Android\Repos\xapk-to-apk\xapktoapk.py", line 77, in execute_command_subprocess rc = call(command_tokens_list, stdout=DEVNULL, stderr=STDOUT) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\subprocess.py", line 345, in call with Popen(*popenargs, **kwargs) as p: File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\subprocess.py", line 971, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1456, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified

DYY-Studio commented 2 weeks ago

Hello, @pirateorno @Evyatar108 That's because in Windows environment we use apktool.bat to run apktool.jar, which shutil CAN but subprocess CAN NOT resolve apktool.bat as an executable file.

So you can edit these 2 line in unpack_apk and pack_apk function from rc = execute_command_subprocess(['apktool', 'd', '-s', apk_file]) to rc = execute_command_subprocess(['apktool.bat', 'd', '-s', apk_file]) Then all solved.

Noticed that in the end of the apktool.bat has

rem Pause when ran non interactively
for %%i in (%cmdcmdline%) do if /i "%%~i"=="/c" pause & exit /b

So the unpacking progress would be PAUSE, waiting for any key input, when one of the unpacking step finish. You should delete it or make it a comment (add an rem in front of the line): rem for %%i in (%cmdcmdline%) do if /i "%%~i"=="/c" pause & exit /b Or just press any key.

And the rc can not get correct code in Windows as Windows Batch always return 0. Maybe we should directly use java -jar to run the apktool.jar instead of apktool.bat

Hope this help!