简体   繁体   English

android NDK加载库-UnsatisfiedLinkError

[英]android NDK loading a library - UnsatisfiedLinkError

i'm developing a android game which uses libgdx and bullet physics engine. 我正在开发一个使用libgdx和bullet物理引擎的android游戏。 I can compile the game without any problems, but when i add bullet to the game it crashes with this error: 我可以毫无问题地编译游戏,但是当我向游戏中添加项目符号时,它会因以下错误而崩溃:

.... UnsatisfiedLinkError: Couldn't load bullet: findLibrary returned null ... .... UnsatisfiedLinkError:无法加载项目符号:findLibrary返回null ...

I can compile the bullet library just fine but when i try to use it in my code it crashes.. The funny thing is that i have another project that uses bullet but without libgdx and it works without any problems. 我可以很好地编译子弹库,但是当我尝试在代码中使用它时会崩溃。.有趣的是,我有另一个使用子弹但没有libgdx的项目,它的工作没有任何问题。 Does any one know what could be the problem? 有谁知道可能是什么问题? From what i know ndk-build generates only .so files and obj folder. 据我所知,ndk-build仅生成.so文件和obj文件夹。

It looks like the bullet .so file isn't included in the .apk, thus the crash. 似乎.apk中未包含项目符号.so文件,因此崩溃了。 How could i check if it is? 我该如何检查呢? Did anyone had any similar problems? 有没有人有类似的问题?

Thanks for the help! 谢谢您的帮助!

i've solved my problem. 我解决了我的问题。 The problem was that libgdx has armeabi and armeabi-v7a folders in libs folder and bullet has only armeabi. 问题在于libgdx在libs文件夹中具有armeabi和armeabi-v7a文件夹,而bullet仅具有armeabi。 So i've removed the armeabi-v7a and it magicly worked! 所以我删除了armeabi-v7a,它神奇地起作用了!

I had this issue show up when I started using .cpp native files instead of .c native files. 当我开始使用.cpp本机文件而不是.c本机文件时,出现了此问题。 The problem was that I wasn't accounting for name-mangling in the .cpp build tools. 问题是,我不占名称的mangling中的.cpp构建工具。 Try adding the following surrounding your native method definitions: 尝试在本机方法定义周围添加以下内容:

#ifdef __cplusplus 
extern "C" {
#endif
    /* ... */
#ifdef __cplusplus
}
#endif

im having a similar problem 我有一个类似的问题

the above post were helpfull though, I checked my game.apk and the so library is under lib/armeabi, but when i build it in eclipse its in libs/armeabi. 上面的文章虽然对我有帮助,但是我检查了我的game.apk,所以so库在lib / armeabi下,但是当我在eclipse中将其构建在libs / armeabi中时。

i think it should be under libs normally and if anybody can help me change lib to libs when building will be really helpfull. 我认为通常应该在libs下,如果有人可以帮助我在构建时将lib换成libs,那将真的很有帮助。

Check that name that is passed to System.loadLibrary is same as .so name in your .apk file. 检查传递给System.loadLibrary的名称是否与.apk文件中的.so名称相同。 Apk file actually is a zip file - so you can rename it to .zip extension, unzip and examine libs folder inside. APK文件实际上是一个zip文件-因此您可以将其重命名为.zip扩展名,解压缩并检查其中的libs文件夹。

So if you have file named libFooBar.so under libs folder in apk file, then you should pass one of following names to loadLibary - "FooBar", "libFooBar" or "libFooBar.so". 因此,如果apk文件中libs文件夹下有一个名为libFooBar.so的文件,则应将以下名称之一传递给loadLibary-“ FooBar”,“ libFooBar”或“ libFooBar.so”。

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

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