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'
基础教程推荐
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01