0

I am importing a .aar file as a dependency in my android project and have added this to Android.mk file.

Now internally this file has dependency on some .so files which its not able to pick up automatically.

So I copied all the dependent .so files under the below structure,

     app --> libs --> arm64-v8a --> test.so 
              |
              |   --> x86 --> test.so 

And now I tried several combination of below config in Android.mk file, but the above test.so file is not getting added to the apk generated after building.

. . . .

    **include $(CLEAR_VARS)

    ifneq (,$(filter $(TARGET_ARCH_ABI), armeabi-v7a x86 arm64-v8a x86_64))
    LOCAL_MODULE := Some Name
    LOCAL_SRC_FILES := sources/app/libs/$(TARGET_ARCH)/xyz.so  //Path of of my local .so file
    LOCAL_MODULE_CLASS := SHARED_LIBRARIES
    include $(PREBUILT_SHARED_LIBRARY)**

I tried lot of googling and also referred Android Xref, but unable to figure out what I am missing.

Any leads?

tejas
  • 2,435
  • 10
  • 37
  • 54

2 Answers2

0

LOCAL_PREBUILT_JNI_LIBS = libs/xxxx.so

See example: https://github.com/ayufan-pine64/proprietary_vendor_google_atv/blob/master/atv/Android.mk

Yong
  • 1,529
  • 12
  • 21
  • Yong, thanks for sharing this. But I assume here the .so files are being referred from a prebuilt apk? In my case I have a .aar module dependency which in turn dependent on .so files. But anyways I will give a try for the mentioned solution – tejas Dec 25 '19 at 07:29
  • @tejas have you solved your problem ? I have same issue with you but i have not solution yet. – TuanPM Feb 10 '20 at 01:55
  • @TuanPM The solution I figured out is push your apk and .so file to both /system/app/ folder and /system/lib64/ folder respectively. Just by installing this doesn't work – tejas Mar 12 '20 at 04:50
0

Best way to add shared library in Android.mk and making sure it will be part of system/lib or system/lib64 based of CPU ARCh is

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := AndroidMediaShell
LOCAL_PRIVILEGED_MODULE := true
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_SRC_FILES := app/$(LOCAL_MODULE).apk
LOCAL_PREBUILT_JNI_LIBS := lib/lib_example.so
LOCAL_MODULE_TARGET_ARCH := arm or arm64 or x86
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_OVERRIDES_PACKAGES :=
include $(BUILD_PREBUILT)
SAURABH_12
  • 2,262
  • 1
  • 19
  • 19