写了个工具类去解析APK包读取里面的信息,在window是环境测试都ok,但是部署到服务器(CentOS)就报错“cannot execute binary file”。
可能的解决方案:
1、如果是没有执行权限,用命令修改即可:chmod +x aapt
2、可能是编译环境不同造成的:请检查是不是因为 32位 64位操作系统导致或者是amd or intel问题导致;
3、如果还报如下错误
“aapt: /lib/libz.so.1: no version information available (required by aapt)”
解决如下:
查了一下,服务器上的libz版本太旧了(libz.so.1.2.3)导致的,下载一个新版本(zlib-1.2.7.tar.gz)即可。
a、tar zxvf zlib-1.2.7.tar.gz
b、./configure
c、make
d、make install 【确保用root用户,否则会提示Permission denied】
e、链接老版本 : ln -s /usr/local/lib/libz.so.1 /lib/libz.so.1 【可能需要先删除原来的软连接】
4、如果还报如下错误
“error while loading shared libraries: libz.so.1: wrong ELF class: ELFCLASS64...”
换成32位的包,重新安装即可。【如果是64位机器的话,执行 export CFLAGS=-m32 ,然后在按步骤3即可】
5、如果上面的办法都不行:The solution that I found for this issue is to download the android sdk for linux,install it, and then grab the aapt file from the platform-tools folder and copy it over the aapt file in lib/android/bin.
参考文章:
http://forums.adobe.com/thread/934859
http://hi.baidu.com/whosafe/item/168890359c7fcc3a2f0f8179