Reputation: 39
I have an android application which also has c++ code dependencies.
I want to build this application as system application by compiling with AOSP.
In my android.mk, I have to first import a static library (abc.a) and then use it to build a shared library (xyz.so).
I am facing build error as "error: xyz (SHARED_LIBRARIES android-arm64) missing abc (STATIC_LIBRARIES android-arm64)"
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := abc
LOCAL_SRC_FILES := $(LOCAL_PATH)/$(TARGET_ARCH_ABI)/abc.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
#LOCAL_LDFLAGS := -llog -ldl
LOCAL_MODULE := libxyz
LOCAL_SRC_FILES := \
xyz.cpp \
xyz1.cpp
LOCAL_STATIC_LIBRARIES := abc
LOCAL_CFLAGS += -Wall -Werror -Wno-unused-parameter -Wno-switch
#LOCAL_SDK_VERSION := 19
#LOCAL_NDK_STL_VARIANT := c++_static # LLVM libc++
include $(BUILD_SHARED_LIBRARY)
Cmakelists:
cmake_minimum_required(VERSION 3.4.1)
add_library( # Sets the name of the library.
abc
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/abc.cpp
src/main/cpp/abc.hxx
......................)
find_library( # Sets the name of the path variable.
log-lib
log pthread)
add_library( xyz
STATIC
IMPORTED )
set_target_properties( # Specifies the target library.
xyz
# Specifies the parameter you want to define.
PROPERTIES IMPORTED_LOCATION
# Provides the path to the library you want to import.
../../../../${ANDROID_ABI}/xyz.a )
target_link_libraries( # Specifies the target library.
abc
xyz ${log-lib} )
Attaching error screenshot.
Upvotes: 3
Views: 7455
Reputation: 10499
The platform build system is not the same as the one used by the NDK. There's no such rule as PREBUILT_STATIC_LIBRARY
or PREBUILT_SHARED_LIBRARY
, so those rules aren't being executed. The platform uses BUILD_PREBUILT
, and you have to specify your LOCAL_MODULE_CLASS
. See https://android.googlesource.com/platform/packages/apps/Dialer/+/refs/heads/master/Android.mk for an example.
CMake is not supported at all in the platform.
You also probably don't want to use Android.mk in the platform. That build system (which is unrelated to ndk-build) has been on its way out for several years. You'll want to use Soong as described by https://source.android.com/setup/build.
Upvotes: 1