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.
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
Here is my Android.mk
file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
EXTRA_CFLAGS := -DANDROID
LOCAL_MODULE := RelayAPI
LOCAL_SRC_FILES := RelayAPI.c
include $(BUILD_EXECUTABLE)
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();
}