无法使用Android-NDK编译外部预编译共享库

时间:2014-06-05 11:13:57

标签: android eclipse android-ndk shared-libraries

我有两个共享库:A.soB.so,并希望将它们与我的Android Project相关联。

  1. 从Eclipse创建一个新的Android项目
  2. 右键点击项目 - > Android工具 - >添加原生支持
  3. 它创建了一个新文件夹:JNIJNI/projectname.cppJNI/Android.mk
  4. 现在我将A.soB.so添加到<Project-folder>/libs/armeabi
  5. 当我构建项目时,我在控制台中获得了这个输出:

    **** 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 ****
    

    我担心的是它没有A.soB.so Project.so。可能是Android.mk文件中缺少的东西

    Android.mk文件的内容:

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

1 个答案:

答案 0 :(得分:4)

您不能只放置预建库。您还需要将其定义为单独的模块。 将A.so和B.so移动到jni文件夹,然后像这样修改Android.mk:

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)