简体   繁体   中英

Not able to compile external precompiled shared library with Android-NDK

I have two shared library: A.so and B.so and want to link them with my Android Project .

  1. Create a new Android Project from Eclipse
  2. Right click on project-> Android Tools-> Add Native support
  3. It created a new folder: JNI , JNI/projectname.cpp and JNI/Android.mk
  4. Now i add A.so and B.so to <Project-folder>/libs/armeabi

When i build the project i got this output in console:

**** Build of configuration Default for project fona ****

/home/users/android-ndk/ndk-build all 
Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml    
[armeabi] Install        : projectname.so => libs/armeabi/libprojectname.so

 *** Build Finished ****

My concern is that it didn't build A.so and B.so with Project.so . May be i am something missing in Android.mk file

Content of Android.mk file:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := projectname
LOCAL_SRC_FILES := projectname.cpp
include $(BUILD_SHARED_LIBRARY)

You can't just place prebuilt libraries. You need to define it as separate modules, too. Move your A.so and B.so to jni folder, and modify your Android.mk like this:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE    := A
LOCAL_SRC_FILES := A.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := B
LOCAL_SRC_FILES := B.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := projectname
LOCAL_SRC_FILES := projectname.cpp
include $(BUILD_SHARED_LIBRARY)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM