androidandroid-ndkandroid-sourceapk

Error adding prebuilt apk with shared libraries to AOSP


I tried to add a prebuilt APK to my Android build. The APK contains several shared libraries (*.so files). It compiles without problem, but I still get an error from the app indicating that the libraries cannot be found.

Why could this be?

Here is the android.mk code:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := apkwithso
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_REQUIRED_MODULES := libx liby libz
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)

libx, y, z are my libx.so, liby.so, and libz.so

I also tried to copy the .so manually from the APK to the out lib directories but it didn't work.

I am compiling with Android 4.1.2 for Galaxy Nexus Maguro.


Solution

  • BUILD_PREBUILT calls prebuild.mk script. The description of this script is the following:

    Standard rules for copying files that are prebuilt

    It does not tell that the application will be installed. So I think that is why your application cannot find the libraries.

    The solution is to extract libraries from the package and copy them separately from the application. The details how to do this you can find here.