简体   繁体   English

将预构建的 NDK 库(.so 文件)添加到 Android 项目

[英]Add pre-built NDK library (.so file) to Android project

I inherited an Android project which includes a sub-project to build a JNI library from C source.我继承了一个 Android 项目,其中包括一个从 C 源代码构建 JNI 库的子项目。 I want to remove the C source and include pre-built library instead.我想删除 C 源代码并包含预构建的库。 Based on tips I found here and there, I copied the .so files from the .apk to paths like: app/src/main/jniLibs/armeabi-v7a/libxcore.so But, when I tried to build the app I get "cannot find symbol" errors for classes defined in the library.根据我在这里和那里找到的提示,我将 .so 文件从 .apk 复制到以下路径: app/src/main/jniLibs/armeabi-v7a/libxcore.so但是,当我尝试构建应用程序时,我得到“库中定义的类的找不到符号”错误。 I'm guessing I need to add something to build.gradle that points to the .so files, but am very new to Java/Android/Gradle and can't figure out what.我猜我需要在 build.gradle 中添加一些指向 .so 文件的内容,但是对于 Java/Android/Gradle 来说我很陌生,不知道是什么。 Tried a variety of things suggested here, with no luck.尝试了这里建议的各种东西,但没有运气。 Thanks for any help.谢谢你的帮助。

The error had nothing to do with the location of the .so files, but with the fact that the library sub-project I deleted also contained some Java sources.该错误与 .so 文件的位置无关,而是因为我删除的库子项目还包含一些 Java 源代码。 Once I added back the original library project, and deleted only the C sources, everything worked fine.一旦我添加回原始库项目并仅删除 C 源代码,一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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