l2m2 / l2m2.github.io

l2m2的技术博客 https://l2m2.top
3 stars 1 forks source link

使用AAPT2生成Android动态换肤需要的APK包 | L2M2 #109

Open l2m2 opened 3 years ago

l2m2 commented 3 years ago

https://l2m2.top/2021/06/17/2021-06-17-using-aapt2/

l2m2 commented 3 years ago

使用aapt2时,若路径中有中文,可能回出现错误。 暂时的解决方案:将路径转换成短路径再处理。 可使用Win32 API GetShortPathNameW进行处理。

l2m2 commented 3 years ago

Python使用Win32 API转换成短路径的一个示例:

from ctypes import *

path = r"E:\workspace\中文\output\tmp\src\com.android.systemui\res"
buf = create_unicode_buffer(260)
GetLongPathName = windll.kernel32.GetShortPathNameW
rv = GetLongPathName(path, buf, 260)
print(buf.value)
l2m2 commented 3 years ago

也可以通过 dir /x 拿到短路径。 详见 https://superuser.com/questions/348079/how-can-i-find-the-short-path-of-a-windows-directory-file