需求:在做一个appstore,有些app的名称和logo不完整,因此需要从apk包中提取apk的信息
工具:使用sdk的aapt工具
下载:从sdk官网下载sdk,入我下载的是android-sdk_r22.6.2-linux
更新:解压下载的tar.gz,android-sdk-linux,由于下载的包中只有add-ons和platforms两个文件夹,没有build-tools,所以需要更新,更新的办法是在自己的vmware 64bit centos中 使用eclipse更新,然后,把android-sdk-linux上传到linux服务器上
服务器1:32bit linux
需要zlib1.2.7及以上版本
[root@*** tech]# tar zxf zlib-1.2.7.tar.gz
[root@*** tech]# cd zlib-1.2.7
[root@*** zlib-1.2.7]# ./configure
Checking for gcc...
Checking for shared library support...
Building shared library libz.so.1.2.7 with gcc.
Checking for off64_t... Yes.
Checking for fseeko... Yes.
Checking for strerror... Yes.
Checking for unistd.h... Yes.
Checking for stdarg.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
Checking for vsnprintf() in stdio.h... Yes.
Checking for return value of vsnprintf()... Yes.
Checking for attribute(visibility) support... Yes.
Looking for a four-byte integer type... Found.
[root@*** zlib-1.2.7]# make
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -I. -c -o example.o test/example.c
...............
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o minigzip64 minigzip64.o -L. libz.a
[root@*** zlib-1.2.7]# make install
cp libz.a /usr/local/lib
chmod 644 /usr/local/lib/libz.a
cp libz.so.1.2.7 /usr/local/lib
chmod 755 /usr/local/lib/libz.so.1.2.7
cp zlib.3 /usr/local/share/man/man3
chmod 644 /usr/local/share/man/man3/zlib.3
cp zlib.pc /usr/local/lib/pkgconfig
chmod 644 /usr/local/lib/pkgconfig/zlib.pc
cp zlib.h zconf.h /usr/local/include
chmod 644 /usr/local/include/zlib.h /usr/local/include/zconf.h
[root@*** zlib-1.2.7]# /home/tech/android-sdk-linux/build-tools/19.0.3/aapt d badging /home/web/cn.wiz.note_6080.apk/home/tech/android-sdk-linux/build-tools/19.0.3/aapt: /usr/lib/libz.so.1: no version information available (required by /home/tech/android-sdk-linux/build-tools/19.0.3/aapt)
W/asset (10494): Asset path /home/web/cn.wiz.note_6080.apk is neither a directory nor file (type=1).
ERROR: dump failed because assets could not be loaded
[root@*** zlib-1.2.7]# ls /usr/local/lib/libz.so.1
/usr/local/lib/libz.so.1
[root@*** zlib-1.2.7]# cp /usr/lib/libz.so.1 /usr/lib/libz.so.1.bak
[root@*** zlib-1.2.7]# cp /usr/local/lib/libz.so.1 /usr/lib/
cp:是否覆盖“/usr/lib/libz.so.1”? y
测试是否安装成功
[root@*** zlib-1.2.7]# /home/tech/android-sdk-linux/build-tools/19.0.3/aapt d badging /home/tech/cn.wiz.note_6080.apk
package: name='cn.wiz.note' versionCode='6080' versionName='6.0.8'
服务器2:64bit centos
[root@*** data01]# android-sdk-linux/build-tools/19.0.3/aapt d badging CMBMobileBank.apk
android-sdk-linux/build-tools/19.0.3/aapt: error while loading shared libraries: libz.so.1: wrong ELF class: ELFCLASS64
根据出现的问题,进行解决
1、配置 zlib
主要是机器是64位的OS,默认编译的.so是64位,而java设置的默认是32位 JDK, 所以会出现这个问题。那么就采用编译成32位的.so, 安装 glibc-devel.i686
然后编译指定 -m32 就可以了
[root@*** data01]# cd zlib-1.2.7
[root@*** zlib-1.2.7]# export CFLAGS=-m32
[root@*** zlib-1.2.7]# ./configure
Checking for gcc...
Checking for shared library support...
No shared library support; try without defining CC and CFLAGS
Building static library libz.a version 1.2.7 with gcc.
Checking for off64_t... No.
Checking for fseeko... No.
Checking for strerror... No.
Checking for unistd.h... No.
Checking for stdarg.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf().
Checking for snprintf() in stdio.h... No.
WARNING: snprintf() not found, falling back to sprintf(). zlib
can build but will be open to possible buffer-overflow security
vulnerabilities.
Checking for return value of sprintf()... No.
WARNING: apparently sprintf() does not return a value. zlib
can build but will be open to possible string-format security
vulnerabilities.
Checking for attribute(visibility) support... Yes.
Looking for a four-byte integer type... Not found.
[root@*** zlib-1.2.7]# make
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -I. -c -o example.o test/example.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o adler32.o adler32.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o crc32.o crc32.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o deflate.o deflate.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o infback.o infback.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o inffast.o inffast.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o inflate.o inflate.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o inftrees.o inftrees.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o trees.o trees.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o zutil.o zutil.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o compress.o compress.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o uncompr.o uncompr.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o gzclose.o gzclose.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o gzlib.o gzlib.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o gzread.o gzread.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o gzwrite.o gzwrite.c
ar rc libz.a adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o example example.o -L. libz.a
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -I. -c -o minigzip.o test/minigzip.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o minigzip minigzip.o -L. libz.a
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/adler32.o adler32.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/crc32.o crc32.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/deflate.o deflate.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/infback.o infback.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/inffast.o inffast.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/inflate.o inflate.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/inftrees.o inftrees.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/trees.o trees.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/zutil.o zutil.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/compress.o compress.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/uncompr.o uncompr.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/gzclose.o gzclose.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/gzlib.o gzlib.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/gzread.o gzread.c
gcc -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/gzwrite.o gzwrite.c
gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map -m32 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o libz.so.1.2.7 adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo -lc
rm -f libz.so libz.so.1
ln -s libz.so.1.2.7 libz.so
ln -s libz.so.1.2.7 libz.so.1
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o examplesh example.o -L. libz.so.1.2.7
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o minigzipsh minigzip.o -L. libz.so.1.2.7
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -I. -D_FILE_OFFSET_BITS=64 -c -o example64.o test/example.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o example64 example64.o -L. libz.a
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -I. -D_FILE_OFFSET_BITS=64 -c -o minigzip64.o test/minigzip.c
gcc -m32 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o minigzip64 minigzip64.o -L. libz.a
[root@*** zlib-1.2.7]# make install
cp libz.a /usr/local/lib
chmod 644 /usr/local/lib/libz.a
cp libz.so.1.2.7 /usr/local/lib
chmod 755 /usr/local/lib/libz.so.1.2.7
cp zlib.3 /usr/local/share/man/man3
chmod 644 /usr/local/share/man/man3/zlib.3
cp zlib.pc /usr/local/lib/pkgconfig
chmod 644 /usr/local/lib/pkgconfig/zlib.pc
cp zlib.h zconf.h /usr/local/include
chmod 644 /usr/local/include/zlib.h /usr/local/include/zconf.h
[root@bbsindex211 data01]# android-sdk-linux/build-tools/19.0.3/aapt d badging CMBMobileBank.apk
android-sdk-linux/build-tools/19.0.3/aapt: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
通过下面可以解决: libstdc++.so.6
http://blog.csdn.net/wzg_1981/article/details/12647873
[root@*** data01]# yum list | grep libstdc++
Repository base is listed more than once in the configuration
compat-libstdc++-296.i686 2.96-144.el6 @anaconda-CentOS-201112091719.x86_64/6.2
compat-libstdc++-33.x86_64 3.2.3-69.el6 @anaconda-CentOS-201112091719.x86_64/6.2
libstdc++.x86_64 4.4.7-4.el6 @base
libstdc++-devel.x86_64 4.4.7-4.el6 @base
libstdc++-docs.x86_64 4.4.7-4.el6 @base
compat-libstdc++-33.i686 3.2.3-69.el6 base
libstdc++.i686 4.4.7-4.el6 base
libstdc++-devel.i686 4.4.7-4.el6 base
[root@*** data01]# yum list available | grep libstdc++
Repository base is listed more than once in the configuration
compat-libstdc++-33.i686 3.2.3-69.el6 base
libstdc++.i686 4.4.7-4.el6 base
libstdc++-devel.i686 4.4.7-4.el6 base
[root@***data01]# yum install compat-libstdc++-33.i686
[root@*** data01]# yum install libstdc++.i686
[root@*** data01]# yum install libstdc++-devel.i686
再次make install就可以了
OK,完成