Jimmy Cu
Jimmy Cu

Reputation: 1

libaudioflinger can't link to prebuilt shared library

I have a prebuilt shared library with name "libaudio_ns.so" and I want the libaudiofinger.so link to this lib. I do as below:

  1. Adding prebuilt lib to android/external/ns/lib/libaudio_ns.so with Android.mk as below:

`include $(CLEAR_VARS)

LOCAL_MODULE := libaudio_ns

LOCAL_MODULE_SUFFIX := .so

LOCAL_MODULE_CLASS := SHARED_LIBRARIES

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

LOCAL_MULTILIB := both

LOCAL_SRC_FILES_arm := lib/libaudio_ns.so

LOCAL_SRC_FILES_arm64 := lib64/libaudio_ns.so

LOCAL_MODULE_TARGET_ARCH := arm arm64

LOCAL_SHARED_LIBRARIES := liblog

LOCAL_MODULE_TAGS := optional

include $(PREBUILT_SHARED_LIBRARY)`

  1. in file framework/av/services/audioflinger/Android.bq, I added "libaudio_ns"

shared_libs: [

"libaudiofoundation",

"libaudiohal",

+"libaudio_ns",

"libaudioprocessing",

"libaudiospdif",

"libaudioutils",

"libcutils",

"libutils",

"liblog", ],

but have an error during compile as below:

[ 99% 719/720] glob vr.prof

[100% 720/720] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja

FAILED: out/soong/build.ninja

out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o

out/soong/build.ninja Android.bp

error: frameworks/av/services/audioflinger/Android.bp:3:1: "libaudioflinger" depends on undefined module "libaudio_ns"

ninja: build stopped: subcommand failed.

15:24:33 soong bootstrap failed with: exit status 1

failed to build some targets (10:29 (mm:ss))

Note: libaudiflinger.so is located in system/lib64

Could you help to fix this issue or give me any suggestion for this problem? Thank you so much!

Upvotes: 0

Views: 483

Answers (1)

Mixaz
Mixaz

Reputation: 4178

I think you need to add libaudio_ns dependency to LOCAL_SHARED_LIBRARIES of audioflinger module.

Since you're adding a prebuilt .so file, you probably could use PRODUCT_COPY_FILES approach, see importing custom SO file to AOSP

EDITED: Sorry, that won't work. Seems that you need to convert .mk file to .bp, and only then Soong will see it.

See https://groups.google.com/g/android-building/c/IjNEMlA5lj4

FYI there's a tool to convert .mk to .bp, called androidmk https://stackoverflow.com/a/48593871/1028256

Upvotes: 0

Related Questions