编译不同体系结构的本机代码(以减小大小)

时间:2014-08-03 16:53:17

标签: android eclipse android-ndk

我有一个我在Android应用中使用的本机库。它在libs文件夹中有4个.so文件(armeabi,armeabi-v7a,mips,x86)。现在,问题是,每个.so文件接近10 MB。这使得apk总大小约为40 mb。我想只包含一个相关架构的.so文件,不包括其他.so文件

这是我的application.mk:

# When we build for google play, we build 4 different apk's, each with
# a different version, by uncommenting one of the pairs of lines below.
# Suppose our base version is X:

# Version X: armeabi
#APP_PLATFORM=android-8
#APP_ABI := armeabi

# Version X+1: armeabi-v7a (Much faster due to the availability of hardware
# FP, but cannot be run in the emulator).
APP_PLATFORM=android-8
APP_ABI := armeabi

# Version X+2: x86 (Requires android-9, so a change needs to be made in
# AndroidManifest.xml too)
#APP_PLATFORM=android-9
#APP_ABI := x86

# Version X+3: mips (Requires android-9, so a change needs to be made in
# AndroidManifest.xml too)
#APP_PLATFORM=android-9
#APP_ABI := mips

ifdef NDK_PROFILER
# The profiler doesn't seem to receive ticks when run on release code.
# Accordingly, we need to build as debug - but this turns optimisations
# off, which is less than ideal.
APP_OPTIM := debug
APP_CFLAGS := -O2
else
APP_OPTIM := release
endif
ifdef V8_BUILD
APP_STL := stlport_static
endif
ifdef MEMENTO
APP_CFLAGS += -DMEMENTO -DMEMENTO_LEAKONLY
endif

# If the ndk is r8b then workaround bug by uncommenting the following line
#NDK_TOOLCHAIN_VERSION=4.4.3

# If the ndk is newer than r8c, try using clang.
#NDK_TOOLCHAIN_VERSION=clang3.1

我是ndk的新手,所以我可能会在某个地方出错,但我有预感,这个Application.mk根本就没有被执行。我如何让它运行?因为即使APP_ABI:= armeabi在那里,我在我编译的apk中获得所有.so文件(使用winrar打开)。

我的问题是,如何告诉.mk为特定架构构建?我的变化将如何反映出来?我只需点击RUN(日食中的绿色三角形)。

PS: 这是我下载的第三方库,所以我真的不知道

中的代码

0 个答案:

没有答案