我正在尝试创建一个android项目,使用编译的.so文件加载一个特殊的openal本机库,我使用cygwin编译,在我的onCreate方法中我有以下代码
System.loadLibrary("openal.so");
我的编译库位于我的libs / armeabi文件夹
中我的两个本机代码文件由一个包含
的.c文件组成#include "com_example_helloopenal_MainActivity.h"
JNIEXPORT jint JNICALL Java_com_example_helloopenal_MainActivity_play
(JNIEnv * env, jobject obj, jstring filename) {
return 0;
}
和包含
的.h文件/* 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
在onCreate中调用的方法play并且在.c文件中写入此时应该在log cat中返回0但是应用程序崩溃时出现以下错误消息
01-20 16:11:51.299:E / AndroidRuntime(10842):java.lang.UnsatisfiedLinkError:无法从loader dalvik.system.PathClassLoader [dexPathList [[zip file“/ data / app]加载openal.so /com.example.helloopenal-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.helloopenal-2,/ vendor / lib,/ system / lib,/ system / lib / arm]]] :findLibrary返回null
我是ndk开发的新手,所以对此问题的原因或性质的任何启发都将不胜感激
在jorges回复中采取纠正措施后更新完整错误日志
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
答案 0 :(得分:1)
您应该将其称为System.loadLibrary("openal");
,而不使用此扩展程序