如何加载本地共享对象,在一个罐子里,从一个Android应用程序? [英] How to load a native shared object, in a jar, from an android application?

查看:160
本文介绍了如何加载本地共享对象,在一个罐子里,从一个Android应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个共享的对象,我会打电话给libFoo.so,反对NDK编译。我有一个Java项目(我称之为'jarlib'),使得使用该共享对象中,通过调用

I've got a shared object, which I'll call 'libFoo.so', compiled against the NDK. I have a java project (I'll call it 'jarlib') that makes use of that shared object, by calling

System.loadLibrary("Foo");

这是java项目,我导出为一个罐子,并在Android应用程序中使用。如果我注释掉有关共享对象的所有位,瓶子做工精细,而且我能够完美地与它进行交互。

That java project, I export as a jar, and use in an android application. If I comment out all the bits about the shared object, the jar works fine, and I'm able to interact with it perfectly.

我可以使用jarlib,与在./lib/armeabi/libFoo.so共享对象一个统一的Andr​​oid应用程序共享对象一起,并加载它所有桃色的。

I can use jarlib, along with the shared object from a Unity android application with the shared object in ./lib/armeabi/libFoo.so, and it loads it up all peachy.

我试图用jarlib和libFoo.so在我的非统一的Andr​​oid应用程序,并调用LoadLibrary绝对拒绝找到libFoo.so。我试过把它,所以它会被包含在我的./lib APK,以及./lib/armeabi,并没有什么似乎使负载通话看看吧。

I'm trying to use the jarlib and libFoo.so in my non-unity android app, and loadLibrary absolutely refuses to find the libFoo.so. I've tried placing it so it will be included in my apk in ./lib, as well as ./lib/armeabi, and nothing seems to make the load call see it.

我试过,包括libFoo.so在./lib或./lib/armeabi的jarlib,但一旦我尝试建立/运行我的Andr​​oid应用程序,有人告诉我:

I've tried including the libFoo.so in ./lib or ./lib/armeabi of the jarlib, but once I try to build/run my android app, I'm told:

The library 'jarlib.jar' contains native libraries that will not run on the device.
The following libraries were found:
  - libFoo.so

此,如果它在./lib(不./lib/armeabi)

with this, if it's in the ./lib (not ./lib/armeabi)

Additionally some of those libraries will interfer with the installation of the application because of their location in lib/
lib/ is reserved for NDK libraries.

我不知道我错过了什么组合,但我敢肯定,这是可以做到的,我只是似乎无法弄清楚如何做到这一点!

I'm not sure what combination I'm missing, but I'm sure it can be done, I just can't seem to figure out how to do it!

推荐答案

嘛!原来,这是一件如此的渺小,这引起了我8小时头痛。

Well! It turns out it was something so tiny, that it caused me eight hours of headaches.

我发现我的libFoo.so不显示在我的app.apk / lib中/ armeabi / libFoo.so喜欢它没有当统一建成的apk。我以为它有一些做这一点,所以我开始寻找设置,以确保我的lib文件夹复制到的APK。

I found that my libFoo.so wasn't showing up in my app.apk/lib/armeabi/libFoo.so like it did when unity built the apks. I assumed it had something to do with that, so I started looking for settings to make sure that my lib folder was copied to the apk.

事实证明,lib文件夹是没有,不过......

As it turns out, the lib folder is not, however...

还记得我怎么说,我试图在(在Android应用端):

Remember how I said I tried it in (on the android application side):

./lib/libFoo.so
-and-
./lib/armeabi/libFoo.so

原来,我需要做的是把它放在一个类似的路径。哦,如此的相似。

Turns out, what I needed to do was put it in a similar path. Oh so similar.

./libs/armeabi/libFoo.so

呀。库。凭借取值

在事实上,当我重新命名文件夹'库',以'库',它改变了文件夹的图标在Eclipse中有它的小机器人标志,如箱或资源文件夹有。果然,当您生成APK,的lib / armeabi文件夹有(注意它的命名中的APK'库',而不是'库'。这仍然让我困惑。)

In fact, when I renamed my folder 'lib' to 'libs', it changed the icon of the folder in eclipse to have the little android symbol on it, like the bin or res folders have. And sure enough, when you build the apk, the lib/armeabi folder is there (notice it's named 'lib' in the apk, and not 'libs'. This still confuses me.)

我的一个同事(这是在做这个项目之前我)告诉我沿线,以前是'库'的文件夹,但无一例外的更高版本,然后改为库 Android的SDK。无论哪种方式,刚刚拿起这个项目,我不知道该文件夹应该被命名为'库',因为它似乎没什么问题。我正要准备拉我的头发了。我在这里希望离开这个已经有人跟我一样的问题,并设法解决它快一点。

One of my co-workers (that was working on this project before me) told me that somewhere along the line, the folder used to be 'lib', but was then changed to 'libs' in a later version of the android SDK. Either way, having just picked up this project, I didn't realize that the folder should have been named 'lib', as it seemed fine to me. I was about ready to pull my hair out. I'm leaving this here in the hopes that SOMEONE has the same problem I did, and manages to solve it a bit faster.

这篇关于如何加载本地共享对象,在一个罐子里,从一个Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆