Search code examples
androidc++android-ndkshared-librariesandroid.mk

Why is ndk-build producing two different libraries, one very large and one smaller?


Why is ndk-build producing two different libraries, one very large and one smaller? And which should I use?

The smaller one is written in a libs/armeabi-v7a folder (the build process creates the folders) and the libs folder is at the same level of the jni folder containing the source being built. The .so file is 747 KB

The bigger one is written in an obj/local/armeabi-v7a folder (again, all created by the build process) and the obj folder is at the same level of the jni folder containing the source being built. The .so file is 6.7 MB.


Solution

  • The smaller one is result of running strip on the bigger one. The smaller one is packed into APK and runs on the device. But don't delete the bigger one! If you encounter a crash in native code, you can use addr2line to attribute the crash repport to source code as

    ${NDK}/toolchains/…/bin/arm-linux-androideabi-addr2line -e obj/local/armeabi-v7a/libshared.so  0022f9d8 000357bb