3

I'm struggling to get a module to compile on Android. It references an already existing shared library -- that I only have the .so and .h files.

My current Android.mk looks like this:

LOCAL_PATH:= $(call my-dir)
EXEC_ARCH := armeabi-v7a    

local_vendorlib_c_includes := $(LOCAL_PATH)/VENDORLIB/include

# VENDORLIBWrapper library
include $(CLEAR_VARS)

LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_SRC_FILES := mylib.cpp
LOCAL_MODULE:= libvendorwrapper
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
LOCAL_LDLIBS := -L$(LOCAL_PATH)/DPS/$(EXEC_ARCH)/
LOCAL_C_INCLUDES := \
    $(call include-path-for, graphics corecg) \
    $(call include-path-for, audio-effects) \
    $(local_dps_c_includes)

LOCAL_CPPFLAGS += -O2 -Wno-unused-parameter
#--verbose

LOCAL_SHARED_LIBRARIES := \
    libcutils \
    libdl \
    libVendorLib
#LOCAL_PREBUILT_LIBS += libVendorLib
LOCAL_REQUIRED_MODULES := libVendorLib

include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE := libVendorLib
LOCAL_SRC_FILES := $(LOCAL_PATH)/VendorLib/$(EXEC_ARCH)/libVendorLib.so
LOCAL_MODULE_TAGS := debug
LOCAL_EXPORT_C_INCLUDES := $(local_vendorlib_c_includes)
include $(PREBUILT_SHARED_LIBRARY)


include $(call all-makefiles-under,$(LOCAL_PATH))

And I am getting the error below:

> ninja: error:
> 'out/target/product/generic/obj/lib/libVendorLib.so.toc', needed by
> 'out/target/product/generic/obj/SHARED_LIBRARIES/libvendorwrapper_intermediates/LINKED/libvendorwrapper.so', missing and no known rule to make it make: *** [ninja_wrapper] Error 1
> make: Leaving directory `/home/donatoaz/WORKING_DIRECTORY'
> 
> #### make failed to build some targets (23 seconds) ####
Donato Azevedo
  • 1,378
  • 1
  • 13
  • 22
  • Hi @AlexCohn, thanks for the input. The project might have been built using Android Studio by the previous contractor, but I was using command line, basically just running `mm -B` – Donato Azevedo Feb 07 '18 at 16:30
  • OK, so the project is based on AOSP, that's where *ninja* pops from. Now this output makes sense. – Alex Cohn Feb 07 '18 at 17:02
  • I am not sure though if it ever reads your **Android.mk** file. Check the **Android.bp** files instead. – Alex Cohn Feb 07 '18 at 17:10
  • I was finally able to build it! I will post an answer for future reference, hope it helps someone else. – Donato Azevedo Feb 07 '18 at 19:40

1 Answers1

6

I was able to finally build it by making the following changes

I was able to build it making the following changes:

include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE := libVendorLib
LOCAL_SRC_FILES := libVendorLib.so # <== Moved the prebuilt lib to root / -- oddly enough, when it was in a subfolder, make would not find it.
LOCAL_MODULE_TAGS := debug
LOCAL_EXPORT_C_INCLUDES := $(local_vendorlib_c_includes)
include $(BUILD_PREBUILT) # <== changed this from PREBUILT_SHARED_LIBRARY

Now I get:

make completed successfully (21 seconds)
Donato Azevedo
  • 1,378
  • 1
  • 13
  • 22
  • I could overcome the issue with respect to the generation of *so.toc file but the make failed next with undefined reference. In my case the Shared Libraries were in different folders so they had their own Android.mk files where I added "LOCAL_MODULE_TAGS := debug". But how to resolve the undefined reference. any help would be of much apreciated. – Nandhan Thiravia Feb 18 '19 at 09:44
  • Can you post more details of the error? I know that the line `include $(call all-makefiles-under,$(LOCAL_PATH))` is meant to include makefiles recursively in your project directory. Perhaps it is a matter of the order in which they are running and your outer makefile depends on an asset generated by one of the inner makefiles. – Donato Azevedo Feb 18 '19 at 12:58