如何导入本机库(.so文件)到Eclipse?机库、文件、so、Eclipse

2023-09-12 22:06:10 作者:趁我情深

我下载了Android PDF阅读器信号源$ C ​​$ C,我试图在Eclipse编译它。相反搞乱Cygwin和重新编译原生的C库,我的朋友说我可以从APK这里提取pre-编译.so文件:

I downloaded the Android PDF Viewer source code and am trying to compile it in Eclipse. Instead of messing with Cygwin and recompiling the native C libraries, my friend said I can just extract the pre-compiled .so files from the APK here:

http://$c$c.google.com/p/apv/downloads/detail?name=apv-0.3.1dev13.apk&can=2&q=

究竟如何我导入这些libpdfview2.so文件到Eclipse项目?

How exactly do I import these libpdfview2.so files into the eclipse project?

更新时间:Eclipse中提供了以下错误,将不会运行:

Updated: Eclipse gives the following error and will not run:

存档所需的库:LIB / armeabi / libpdfview2.so项目APV无法读取或不是有效的ZIP文件

Archive for required library: 'lib/armeabi/libpdfview2.so' in project 'APV' cannot be read or is not a valid ZIP file

推荐答案

看他们如何设置的东西,在示例项目: http://$c$c.google.com/p/apv/source/browse/#hg%2Fpdfview

See how they set things up in the sample project: http://code.google.com/p/apv/source/browse/#hg%2Fpdfview

这NDK教程也可能是有用的帮助你找出如何工作的NDK条款: http://mobile.tutsplus.com/tutorials/android/ndk-tutorial/

This NDK tutorial may also be useful in terms of helping you figure out how things work with the NDK: http://mobile.tutsplus.com/tutorials/android/ndk-tutorial/

的基本是这样的:

的.so库文件通常走在project_root_dir /库子文件夹。此外,他们一般都在描述他们的建筑进一步的子文件夹(如project_root_dir /库/ armeabi / libpdfview2.so)。

The .so library files typically go in the project_root_dir/libs subfolder. Also, generally they are in further subfolders that describe their architecture (e.g. project_root_dir/libs/armeabi/libpdfview2.so).

要使用这个库中的活动添加静态库加载到活动中,如下所示:

To use the library in an activity you add a static library loader to the activity as shown below:

静态 {     的System.loadLibrary(pdfview2); //注意缺少LIB $ P $的PFIX }

static { System.loadLibrary("pdfview2"); // Notice lack of lib prefix }

您然后定义要导入的本地函数。您可以识别这些功能要归功于本土关键字。看看下面的文件中看到,他们的样本中导入哪些功能:

You then define the native functions you are importing. You can recognize these functions thanks to the native keyword. Look in the file below to see what functions they import in the sample:

http://$c$c.google.com/p/apv/source/browse/pdfview/src/cx/hell/android/pdfview/PDF.java?r=560343d2dad904c5c925b6cadf97b90430fd25f4

下面是一些例子:

private native int parseBytes(byte[] bytes);  
private native int parseFile(String fileName);  
private native int parseFileDescriptor(FileDescriptor fd);