不满意的链接错误Android Eclipse
Posted
技术标签:
【中文标题】不满意的链接错误Android Eclipse【英文标题】:Unsatisfied Link Error Android Eclipse 【发布时间】:2016-04-26 14:36:52 【问题描述】:我正在尝试创建一个 android 项目,该项目使用我使用 cygwin 编译的已编译 .so 文件加载本机库,特别是 openal,在我的 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 中调用并写入 .c 文件的方法 play 此时应在 log cat 中返回 0,但应用程序崩溃并显示以下错误消息
01-20 16:11:51.299: E/AndroidRuntime(10842): java.lang.UnsatisfiedLinkError: 无法从加载器 dalvik.system.PathClassLoader[DexPathList[[zip 文件”/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 ComponentInfocom.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 AppWindowToken2252f9c0 token=Token2269a480 ActivityRecord2203eab0 u0 com.example.helloopenal/.MainActivity t28 timed out
01-20 17:01:19.089: E/AppsCustomizePagedView(900): Widget ComponentInfocom.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
【问题讨论】:
【参考方案1】:你应该把它称为System.loadLibrary("openal");
没有这样的扩展名
【讨论】:
进行此更改时,我仍然遇到同样的问题 我现在收到另一个错误对不起,新错误如下: 01-20 17:01:08.549: E/AndroidRuntime(12046): java.lang.UnsatisfiedLinkError: dlopen failed: " /data/app-lib/com.example.helloopenal-2/libopenal.so" 有意外的 e_machine: 40 看不到完整的日志 请确保您的设备是受支持的架构,否则请尝试为其添加支持How to target multiple architectures using NDK? 在我的 Android.mk 文件的顶部我有这些行 TARGET_PLATFORM := android-4 ROOT_PATH := $(call my-dir) APP_ABI := all (根据我的知识和你发布的链接这条线应该按照你的建议做是吗?)以上是关于不满意的链接错误Android Eclipse的主要内容,如果未能解决你的问题,请参考以下文章
android+eclipse+mysql+servlet(Android与mysql建立链接)
链接器错误,在 ubuntu 15.04 上使用 OpenCV 和 Eclipse CDT