Reputation: 314
I've a .so file which is being referenced by other project in AOSP system package. To make referencing possible I've created a new project in AOSP/external package with two files in it viz Android.mk and the xyz.so file. The Android.mk looks like following.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := customutil
LOCAL_SRC_FILES := xyz.so
include $(PREBUILT_SHARED_LIBRARY)
During the compilation it gives me following error.
make: * No rule to make target out/target/product/crespo/obj/lib/customutil.so', needed by
out/target/product/crespo/obj/EXECUTABLES/abc_agent_intermediates/LINKED/abc_agent'. Stop.
Where should I keep, xyz.so file or what changes should I make so that when I build AOSP, it won't trow this error?
Sushil
Upvotes: 2
Views: 2971
Reputation: 2310
I added my prebuilt .so file in external folder of AOSP source code as following:-
Step 1 :- I have created one folder(let say myLibs) inside external folder of AOSP then I added my .so file in it and added following code in Android.mk file
# Prebuilt Lib
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libMyabc # your lib name
LOCAL_SRC_FILES := libMyabc.so
# your lib .so file name
include $(BUILD_SHARED_LIBRARY)
Then i added my shared libs name in Frameworks/base/core/jni/Android.mk file in LOCAL_SHARED_LIBRARIES section.
Now it is generation my .so file in out/target/product/generic/obj/lib folder
Thanks Happy Coding...
Upvotes: 0
Reputation: 2113
By default, for prebuilts, LOCAL_SRC_FILES are relative to your current LOCAL_PATH definition, so if your Android.mk is under $PROJECT/jni/Android.mk
, you should put it at $PROJECT/jni/xyz.so
The name should also be probable libxyz.so instead of xyz.so (though that might work without the lib prefix).
If you plan to support several CPU ABIs, try to use a sub-directory, as in:
include $(CLEAR_VARS)
LOCAL_MODULE := libxyz
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libxyz.so
include $(PREBUILT_SHARED_LIBRARY)
And place the files under:
$PROJECT/jni/armeabi/libxyz.so
$PROJECT/jni/armeabi-v7a/libxyz.so
$PROJECT/jni/x86/libxyz.so
...
Finally, you can also use an absolute path for LOCAL_SRC_FILES, and the build system will pick the file from there.
Upvotes: 0
Reputation: 3540
Your module rules are a problem.
when you have a pre-built library with LOCAL_MODULE := customutil
, then the linker will get the additional flag -lcustomutil
. Thus your LOCAL_SRC_FILES :=
needs to be LOCAL_SRC_FILES := libcustomutil.so
Thus the Android.mk section should be:
# Prebuilt Lib
include $(CLEAR_VARS)
LOCAL_MODULE := xyx
LOCAL_SRC_FILES := libxyz.so
include $(PREBUILT_SHARED_LIBRARY)
This also means that you need to rename the library appropriately or set the module name according to the library name.
Upvotes: 1