Android - #39;Couldn#39;t load Foo: findLibrary returned null#39;(Android - 无法加载 Foo:findLibrary 返回 null)
问题描述
我知道已经有关于堆栈溢出错误的帖子,但从我在 SO 和 Google 上找到的内容来看,这与我的问题不符.
I know that there are already posts about this error around stack overflow, but from what I have found here on SO and on Google don't line up with my problem.
我正在尝试运行我的应用程序,但是每当调用本机函数时,我的程序就会崩溃,并且我得到以下 LogCat
...
I am trying to run my application, but whenever a native function is called my program crashes, and I get the following LogCat
...
08-01 09:15:57.448: E/AndroidRuntime(16966): FATAL EXCEPTION: main
08-01 09:15:57.448: E/AndroidRuntime(16966): java.lang.ExceptionInInitializerError
08-01 09:15:57.448: E/AndroidRuntime(16966): at my.eti.commander.MainMenu.initMain(MainMenu.java:241)
08-01 09:15:57.448: E/AndroidRuntime(16966): at my.eti.commander.MainMenu.onCreate(MainMenu.java:81)
08-01 09:15:57.448: E/AndroidRuntime(16966): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-01 09:15:57.448: E/AndroidRuntime(16966): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-01 09:15:57.448: E/AndroidRuntime(16966): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-01 09:15:57.448: E/AndroidRuntime(16966): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-01 09:15:57.448: E/AndroidRuntime(16966): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-01 09:15:57.448: E/AndroidRuntime(16966): at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 09:15:57.448: E/AndroidRuntime(16966): at android.os.Looper.loop(Looper.java:130)
08-01 09:15:57.448: E/AndroidRuntime(16966): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-01 09:15:57.448: E/AndroidRuntime(16966): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 09:15:57.448: E/AndroidRuntime(16966): at java.lang.reflect.Method.invoke(Method.java:507)
08-01 09:15:57.448: E/AndroidRuntime(16966): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-01 09:15:57.448: E/AndroidRuntime(16966): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-01 09:15:57.448: E/AndroidRuntime(16966): at dalvik.system.NativeStart.main(Native Method)
08-01 09:15:57.448: E/AndroidRuntime(16966): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load RelayAPI: findLibrary returned null
08-01 09:15:57.448: E/AndroidRuntime(16966): at java.lang.Runtime.loadLibrary(Runtime.java:429)
08-01 09:15:57.448: E/AndroidRuntime(16966): at java.lang.System.loadLibrary(System.java:554)
08-01 09:15:57.448: E/AndroidRuntime(16966): at my.eti.commander.RelayAPIModel$NativeCalls.<clinit>(RelayAPIModel.java:432)
08-01 09:15:57.448: E/AndroidRuntime(16966): ... 15 more
这是我的 Android.mk
文件:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
EXTRA_CFLAGS := -DANDROID
LOCAL_MODULE := RelayAPI
LOCAL_SRC_FILES := RelayAPI.c
include $(BUILD_EXECUTABLE)
这是我的 jni 文件夹的图片...只会使用 RelayAPI,stringstuff 是一个未使用的额外文件.
Here is a picture of my jni folder...Only RelayAPI will be used, stringstuff is an extra file that isn't used.
我将所有本机函数存储在一个单独的类中,以便可以静态调用它们.不过这不是问题,因为我一直在移动它们,但我只是认为这将是我完成它的最佳方式.
I store all of my native functions in a separate class so that they can be called statically. This isn't the problem though, because I've been moving them around quite a bit but I just decided this would be the best way for me to get it done.
public static class NativeCalls {
static {
System.loadLibrary( "RelayAPI");
}
public native static byte InitRelayJava();
public native static void FreeRelayJava();
}
推荐答案
好吧,我已经通过了错误.上个月我问了一个不同的问题,在尝试解决这个问题时,这个错误消失了.它与将我的 environment PATH variable
设置为 NDK 文件夹位置有关.这是一个更深入的答案的链接.
Well, I've gotten passed the error. I had asked a different question last month, and while trying to solve that, this error went away. It had to do with setting my environment PATH variable
to the NDK folder location. This is a link to a more in depth answer.
这篇关于Android - '无法加载 Foo:findLibrary 返回 null'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android - '无法加载 Foo:findLibrary 返回 null'


- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01