Android studio 如何在android studio中使用现有的.so?

Android studio 如何在android studio中使用现有的.so?,android-studio,android-ndk,shared-libraries,shared-objects,Android Studio,Android Ndk,Shared Libraries,Shared Objects,1.我有一个现有的。so,由以下人员编制: arm-linux-androideabi-g++*.cpp-o libshow\u demo.so-fPIC-shared 2.然后我把它放到android studio3.0.1的项目文件夹中 3.我在Android scope add下编辑渐变 源集{ 主要{ jniLibs.srcDir(['src/main/libs'])} 4.然后我通过添加以下内容编辑Cmakelists.txt: add_library( # Sets the nam

1.我有一个现有的。so,由以下人员编制:

arm-linux-androideabi-g++*.cpp-o libshow\u demo.so-fPIC-shared

2.然后我把它放到android studio3.0.1的项目文件夹中

3.我在Android scope add下编辑渐变

源集{ 主要{ jniLibs.srcDir(['src/main/libs'])}

4.然后我通过添加以下内容编辑Cmakelists.txt:

add_library( # Sets the name of the library.
         show_demo
         # Sets the library as a shared library.
         SHARED
         # Provides a relative path to your source file(s).
         IMPORTED )
set_target_properties( # Specifies the target library.
                       show_demo
                       # Specifies the parameter you want to define.
                       PROPERTIES IMPORTED_LOCATION
                       # Provides the path to the library you want to import.
                       src/main/libs/libshow_demo.so )
include_directories( show_demo/include/ )
target_link_libraries( # Specifies the target library.
                       native-lib show_demo
                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib} )
5.错误来了。我无法纠正Gradle,它显示错误:

Error:FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process /Users/bertie/Library/Android/sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /Users/bertie/AndroidStudioProjects/Demo/app/.externalNativeBuild/cmake/debug/arm64-v8a --target native-lib}
  ninja: error: 'src/main/libs/libshow_demo.so', needed by '../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so', missing and no known rule to make it
如何在android studio中使用共享对象?
非常感谢:从您的标题和描述中,我知道您只想在APK中包含一个现有的共享对象库


为此,只需将库添加到src/main/jniLibs/armeabi/libDummy.sosrc/main/jniLibs/x86/libDummy.so,具体取决于所需和运行的体系结构!!适用于我:)

您是否为arm64-v8a构建了libshow\u demo.so?如果没有,您可以选择:为您构建其他共享库的所有ABI构建libshow_demo.so,或者仅为您构建libshow_demo.so的ABI构建其他共享库(通过向构建脚本添加abiFilter)。您的描述缺少关键部分,文件/Users/bertie/AndroidStudioProjects/Demo/app/build.gardle。此外,发布CMakeLists.txt的完整内容,此脚本也需要修复。