0

I am attempting to create an android project that loads a native libary specifically openal using a compiled .so file which I used cygwin to compile, in my onCreate method i have the following code

System.loadLibrary("openal.so");

and my compiled libaries are in my libs/armeabi folder

my two native code files consist of a .c file containing

#include "com_example_helloopenal_MainActivity.h"

JNIEXPORT jint JNICALL Java_com_example_helloopenal_MainActivity_play
(JNIEnv * env, jobject obj, jstring filename) {
return 0;
}

and a .h file containing

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_example_helloopenal_MainActivity */

#ifndef _Included_com_example_helloopenal_MainActivity
#define _Included_com_example_helloopenal_MainActivity
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class:     com_example_helloopenal_MainActivity
* Method:    play
* Signature: (Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_com_example_helloopenal_MainActivity_play
(JNIEnv *, jobject, jstring);

#ifdef __cplusplus
}
#endif
#endif

the method play called in the onCreate and written in the .c file should return 0 in log cat at this point but instead the application crashes with the following error message

01-20 16:11:51.299: E/AndroidRuntime(10842): java.lang.UnsatisfiedLinkError: Couldn't load openal.so from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.helloopenal-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.helloopenal-2, /vendor/lib, /system/lib, /system/lib/arm]]]: findLibrary returned null

I am new to ndk development so any enlightment on the cause or nature of this issue would be appreciated

Update of full error log after corrective action in jorges reply

01-20 17:01:06.299: E/memtrack(12000): Couldn't load memtrack module (No such file or directory)
01-20 17:01:06.299: E/android.os.Debug(12000): failed to load memtrack module: -2
01-20 17:01:07.479: E/ivpg-hwc(156): Lost 1 flips
01-20 17:01:07.479: E/ivpg-hwc(156): Lost 1 flips
01-20 17:01:07.939: E/NetworkScheduler.SchedulerReceiver(750): Invalid parameter app
01-20 17:01:07.939: E/NetworkScheduler.SchedulerReceiver(750): Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
01-20 17:01:08.069: E/AppsCustomizePagedView(900): Widget ComponentInfo{com.kobobooks.android/com.kobobooks.android.widget.StoreWidgetProvider} can not fit on this device (1062, 1200)
01-20 17:01:08.359: E/memtrack(12024): Couldn't load memtrack module (No such file or directory)
01-20 17:01:08.359: E/android.os.Debug(12024): failed to load memtrack module: -2
01-20 17:01:08.549: E/dalvikvm(12046): Houdini dlopen("/data/app-lib/com.example.helloopenal-2/libopenal.so") failed: Can't load ARM library
01-20 17:01:08.549: E/AndroidRuntime(12046): FATAL EXCEPTION: main
01-20 17:01:08.549: E/AndroidRuntime(12046): Process: com.example.helloopenal, PID: 12046
01-20 17:01:08.549: E/AndroidRuntime(12046): java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app-lib/com.example.helloopenal-2/libopenal.so" has unexpected e_machine: 40
01-20 17:01:08.549: E/AndroidRuntime(12046):    at java.lang.Runtime.loadLibrary(Runtime.java:364)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at java.lang.System.loadLibrary(System.java:526)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at com.example.helloopenal.MainActivity.onCreate(MainActivity.java:15)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at android.app.Activity.performCreate(Activity.java:5231)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2304)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at android.app.ActivityThread.access$900(ActivityThread.java:142)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at android.os.Handler.dispatchMessage(Handler.java:102)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at android.os.Looper.loop(Looper.java:149)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at android.app.ActivityThread.main(ActivityThread.java:5097)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at java.lang.reflect.Method.invokeNative(Native Method)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at java.lang.reflect.Method.invoke(Method.java:515)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)
01-20 17:01:08.549: E/AndroidRuntime(12046):    at dalvik.system.NativeStart.main(Native Method)
01-20 17:01:08.939: E/NetworkScheduler.SchedulerReceiver(750): Invalid parameter app
01-20 17:01:08.939: E/NetworkScheduler.SchedulerReceiver(750): Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
01-20 17:01:10.899: E/ivpg-hwc(156): Lost 1 flips
01-20 17:01:10.899: E/ivpg-hwc(156): Lost 1 flips
01-20 17:01:18.449: E/WindowManager(523): Starting window AppWindowToken{2252f9c0 token=Token{2269a480 ActivityRecord{2203eab0 u0 com.example.helloopenal/.MainActivity t28}}} timed out
01-20 17:01:19.089: E/AppsCustomizePagedView(900): Widget ComponentInfo{com.kobobooks.android/com.kobobooks.android.widget.StoreWidgetProvider} can not fit on this device (1062, 1200)
01-20 17:01:19.919: E/ivpg-hwc(156): Lost 1 flips
01-20 17:01:19.919: E/ivpg-hwc(156): Lost 1 flips
01-20 17:01:46.559: E/ivpg-hwc(156): Lost 1 flips
Lal
  • 14,726
  • 4
  • 45
  • 70
coderon
  • 1
  • 2

1 Answers1

1

You should call it as System.loadLibrary("openal"); without so extension

Jorge Mendez
  • 674
  • 4
  • 15
  • I am still getting the same problem when i make this change – coderon Jan 20 '16 at 16:56
  • I am now receiving a different error sorry, the new error is as follows: 01-20 17:01:08.549: E/AndroidRuntime(12046): java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app-lib/com.example.helloopenal-2/libopenal.so" has unexpected e_machine: 40 – coderon Jan 20 '16 at 17:04
  • Can't see the full log – Jorge Mendez Jan 20 '16 at 17:07
  • Please make sure your device is a supported architecture, otherwise try adding support to it [How to target multiple architectures using NDK?](http://stackoverflow.com/questions/14420312/how-to-target-multiple-architectures-using-ndk) – Jorge Mendez Jan 20 '16 at 17:15
  • At the top of my Android.mk file i have these lines TARGET_PLATFORM := android-4 ROOT_PATH := $(call my-dir) APP_ABI := all (From my knowledge and the link you posted this line should do what you suggested yes ?) – coderon Jan 20 '16 at 17:19