在共享主机上运行 aapt 二进制文件

在共享主机上运行 aapt 二进制文件

我想在我的共享主机上运行 aapt 二进制文件,以便我可以在某些脚本中使用它。我已经在本地安装了 aapt ( sudo apt install aapt),并将其上传到home/user/bin共享主机上的文件夹中,并设置了执行位。当我通过 ssh 运行它时,出现此错误:

aapt: error while loading shared libraries: libaapt.so.0: cannot open shared object file: No such file or directory

因此,我找到本地 aapt 所需的库文件,收集并压缩它们。上传并解压到home/user/lib文件夹中。

zip -j libs.zip $(ldd /usr/bin/aapt | grep "=>" | sed -e "s/(.*//" -e "s/.*=> //")

当我现在在共享主机上执行 aapt(或任何其他命令)时,我遇到了分段错误。

因此,我将所有库文件移至home/user/lib/aapt并执行 aapt。每次我收到缺少 lib 文件的错误时,我都会将缺少的库移回文件夹,home/user/lib直到出现以下内容:

lib:
aapt/
lib7z.so
libaapt.so.0
libandroidfw.so.0
libbacktrace.so.0
libbase.so.0
libcutils.so.0
liblog.so.0
libpng16.so.16
libunwind.so.0
libutils.so.0
libziparchive.so.0

lib/aapt:
libc.so.6*
libexpat.so.1
libgcc_s.so.1
libm.so.6
libpthread.so.0*
libstdc++.so.6
libz.so.1

当我现在运行 aapt 时,出现以下错误:

aapt: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by aapt)
aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by aapt)
aapt: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /home/user/lib/libaapt.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/user/lib/libaapt.so.0)
aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/user/lib/libaapt.so.0)
aapt: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by /home/user/lib/libutils.so.0)
aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/user/lib/libutils.so.0)
aapt: /lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by /home/user/lib/libpng16.so.16)
aapt: /lib64/libz.so.1: version `ZLIB_1.2.3.4' not found (required by /home/user/lib/libpng16.so.16)
aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/user/lib/libpng16.so.16)
aapt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by /home/user/lib/libandroidfw.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /home/user/lib/libandroidfw.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/user/lib/libandroidfw.so.0)
aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/user/lib/libandroidfw.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by /home/user/lib/liblog.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by /home/user/lib/liblog.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /home/user/lib/liblog.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/user/lib/liblog.so.0)
aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/user/lib/liblog.so.0)
aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/user/lib/libcutils.so.0)
aapt: /lib64/libc.so.6: version `GLIBC_2.15' not found (required by /home/user/lib/libcutils.so.0)
aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/user/lib/libbacktrace.so.0)
aapt: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by /home/user/lib/libbacktrace.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/user/lib/libbacktrace.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/user/lib/libbacktrace.so.0)
aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/user/lib/libziparchive.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/user/lib/libziparchive.so.0)
aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/user/lib/libbase.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /home/user/lib/libbase.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/user/lib/libbase.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/user/lib/libbase.so.0)
aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/user/lib/libunwind.so.0)
aapt: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/user/lib/lib7z.so)
aapt: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /home/user/lib/lib7z.so)
aapt: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/user/lib/lib7z.so)

如果我将 libc.so.6 或 libstdc++.so.6 文件移到 lib 文件夹中,我会再次收到分段错误,因为它们会干扰我认为依赖于另一个版本的主机系统库文件。

这就是我遇到的困难,我的问题是如何让 aapt 二进制文件指向 aapt 文件夹中的不同库?

我最好不想进行任何重新编译为静态二进制文件,因为这超出了我的能力范围,并且希望暂时保持这种状态。

答案1

您需要设置一个LD_LIBRARY_PATH包含.so从本地系统上传的文件的目录。

user@host:~$ export LD_LIBRARY_PATH=/home/user/lib/ /path/to/aapt ...

您可以检查是否aapt找到它们,如果找到,则使用ldd /path/to/appt/binary

但看起来好像一些系统.so文件的版本不匹配,因此您可能需要从本地系统查找并上传更多文件。

答案2

最终我让它工作了!最初我编写了一个脚本,使用 apktool 来反编译 apk 并提取我需要的信息(apk 标签和版本号),但这个过程虽然可以运行,但速度相当慢,每个 apk 大约需要 5 或 6 秒。然后我发现了一个 perl 模块,可以通过以下说明在主机上运行 aapt这里

相关内容