Fork me on GitHub

11/23/2012

[Android] Pack 3rd-party shared library .jar/.so into apk by Android.mk

When building android application package by Eclipse, the shared library placed in libs/armeabi* will be packed into apk automatically.
If the building process is from android source tree, the Android.mk needs to be written. So, how to pack 3rd-party shared library .jar/.so into apk by Android.mk?
For .jar
# the name is just a name, it will map to real .jar later
LOCAL_STATIC_JAVA_LIBRARIES := refJar1 \
                               refJar2

# here maps to actual .jar location
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := refJar1 :libs/oooo.jar\
                                        refJar2 :libs/xxxx.jar
For .so
# Put .so to out/target/product/***/obj/lib
$(shell cp $(wildcard $(LOCAL_PATH)/libs/armeabi/*.so) $(TARGET_OUT_INTERMEDIATE_LIBRARIES)) 

LOCAL_JNI_SHARED_LIBRARIES := libs/libxxxx

References

  1. 在apk裡打包進.so文件的方法: http://blog.csdn.net/androidboy365/article/details/6772890
  2. Android build system分析: http://blog.csdn.net/ccskyer/article/details/6122963
  3. android 內置app編譯方法及Android.mk中的系統變量說明: http://bbs.ancode.org/forum.php?mod=viewthread&tid=86
  4. Android NDK開發指南---Android.mk文件: http://hualang.iteye.com/blog/1140414
  5. Android Application, Android Libraries and Jar Libraries: http://devmaze.wordpress.com/2011/05/22/android-application-android-libraries-and-jar-libraries/

No comments:

Post a Comment