patch-apk icon indicating copy to clipboard operation
patch-apk copied to clipboard

FileNotFoundError on "Rebuilding as a single APK." for all split apks

Open cristibctr opened this issue 4 years ago • 1 comments

I'll give Duolingo as an example. I tried with 3 versions of apktools and i get the same error. Using windows 11 and Powershell.

While writing this I found a (maybe temporary) fix. subprocess.run() needs to have "shell=True" on windows.

PS C:\Users\crist\FR test> python patch-apk.py duolingo
Getting APK path(s) for package: com.duolingo
[+] APK path: /data/app/~~IXQViCE2JBXFrKPEn7Gosw==/com.duolingo-K2q48xGyHD-SsAk3yFI9lA==/base.apk
[+] APK path: /data/app/~~IXQViCE2JBXFrKPEn7Gosw==/com.duolingo-K2q48xGyHD-SsAk3yFI9lA==/split_config.arm64_v8a.apk
[+] APK path: /data/app/~~IXQViCE2JBXFrKPEn7Gosw==/com.duolingo-K2q48xGyHD-SsAk3yFI9lA==/split_config.xxhdpi.apk

Pulling APK file(s) from device.
[+] Pulling: com.duolingo-base.apk
[+] Pulling: com.duolingo-split_config.arm64_v8a.apk
[+] Pulling: com.duolingo-split_config.xxhdpi.apk

App bundle/split APK detected, rebuilding as a single APK.

Extracting individual APKs with apktool.
[+] Extracting: C:\Users\crist\AppData\Local\Temp\tmpx08lxloc\com.duolingo-base.apk
[+] Extracting: C:\Users\crist\AppData\Local\Temp\tmpx08lxloc\com.duolingo-split_config.arm64_v8a.apk
[+] Extracting: C:\Users\crist\AppData\Local\Temp\tmpx08lxloc\com.duolingo-split_config.xxhdpi.apk

Copying files and directories from split APKs into base APK.

Found public.xml in the base APK, fixing resource identifiers across split APKs.
[+] Resolving 77 resource identifiers.
[+] Located 77 true resource names.
[+] Updated 77 dummy resource names with true names in the base APK.
[+] Updated 135 references to dummy resource names in the base APK.

Found styles.xml in the base APK, checking for duplicate <style> -> <item> elements and removing.
[~] Warning: this is a complete hack and may impact the visuals of the app, disable with --disable-styles-hack.

Disabling APK splitting in AndroidManifest.xml of base APK.

Rebuilding as a single APK.
Traceback (most recent call last):
  File "C:\Users\crist\FR test\patch-apk.py", line 646, in <module>
    main()
  File "C:\Users\crist\FR test\patch-apk.py", line 30, in main
    apkfile = getTargetAPK(pkgname, apkpaths, tmppath, args.disable_styles_hack)
  File "C:\Users\crist\FR test\patch-apk.py", line 258, in getTargetAPK
    return combineSplitAPKs(pkgname, localapks, tmppath, disableStylesHack)
  File "C:\Users\crist\FR test\patch-apk.py", line 310, in combineSplitAPKs
    elif getApktoolVersion() > pkg_resources.parse_version("2.4.2"):
  File "C:\Users\crist\FR test\patch-apk.py", line 155, in getApktoolVersion
    proc = subprocess.run(["apktool", "-version"], stdout=subprocess.PIPE)
  File "C:\Users\crist\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\crist\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\crist\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

cristibctr avatar Aug 22 '21 11:08 cristibctr

there is also the same fix as the one for runApkTool()

AlexisHamon avatar Sep 08 '21 21:09 AlexisHamon