使用 Eclipse 加载 Android 原生库
我对 Android 开发相当陌生,我已经尝试了一段时间,但我就是不明白。我正在为 android 编写一个创建 gif 的应用程序,为此我正在使用 这个库。我将其编译为 .so 但现在我只是不明白如何实际加载它。我把 .so 放在 /libs/armeabi/ 中,但是当我加载它时,
static {
System.loadLibrary("gifflen");
}
它会抛出
ERROR/AndroidRuntime(13565): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load gifflen: findLibrary returned null
异常,我应该把它放在其他地方吗?或者这是因为我应该更改 Eclipse 中的某些设置? 我已经对 Java 构建路径中的本机库选项进行了修改,但这似乎不是我正在寻找的。 我还用谷歌搜索了一下,找到了一个答案,说选择“Android Tools->Add Native Support”,但我没有这个选项。
I'm fairly new to Android development and I've been trying for a while now but I just don't get it. I'm writing an app for android that creates gifs, and for that I'm using this library. I compiled it into an .so but now I just don't understand how to actually load it. I put the .so in /libs/armeabi/ but when I load it like
static {
System.loadLibrary("gifflen");
}
it throws
ERROR/AndroidRuntime(13565): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load gifflen: findLibrary returned null
Am I supposed to put it somewhere else? Or is this because of some setting in Eclipse I was supposed to change?
I've mucked about with the native library option in Java Build Path but that doesn't seem to be what I'm looking for.
I've also googled around a bit and found an answer that said to select select Android Tools->Add Native Support but I don't have that option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你内置到了 .so 如何?使用NDK?如果是这样,那么创建的文件应该被称为 libgrifflen.so。是吗?
You built into into an .so how? Using the NDK? If so then the file that was created should have been called libgrifflen.so. Was it?
实质上,您需要告诉系统这样的库存在以及它位于哪里。这是在 Eclipse 中完成的,方法是右键单击项目名称,然后选择“Android Tools”,然后选择“Add Native Support”。如果项目已经有本机支持,则不存在此选项 - 如果您是初学者,最好从头开始创建一个新项目。
Substantially, you need to tell the system that such library exists and where it is located. This is done inside Eclipse by right-clicking on the project name and then selecting "Android Tools" and then "Add Native Support". If the project already has Native Support, this option is not present - if you are a beginner it is better that you create a new project from scratch.