I have an android project with such structure:
App
settings.gradle
library
library
library1
library2
library
depends on library1
and library2
.
App settings.gradle
is:
....
include ':library-library1'
include ':library-library2'
include ':library-library'
....
library
build.gradle
looks like this:
android{
....
}
dependencies {
implementation project(':library-library1')
implementation project(':library-library2')
}
library
Android.mk
file:
....
LOCAL_MODULE := library
LOCAL_SRC_FILES := library.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../library1/include
$(LOCAL_PATH)/../../library2/include
LOCAL_LDLIBS :=
-L$(LOCAL_PATH)/../../library1/build/intermediates/library_jni/$(BUILD_TYPE)/jni/$(TARGET_ARCH_ABI)
-L$(LOCAL_PATH)/../../library2/build/intermediates/library_jni/$(BUILD_TYPE)/jni/$(TARGET_ARCH_ABI)
-llog -landroid -llibrary1 -llibrary2
LOCAL_CPPFLAGS += -fexceptions
include $(BUILD_SHARED_LIBRARY)
....
The problem is that build fails on the first run with errors:
"error: cannot find -llibrary1"
"error: cannot find -llibrary2"
And I see that Android Studio creates .so
files for both library1
and library2
after first build run. On the second and other runs everything is OK. So it looks like wrong build order – library
builds before it’s dependencies.
What is the proper way to specify a dependencies for the library
?
livfan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.