1

我有两个设备。一个是运行 2.3.6 的 HTC Nexus-One,另一个是运行 2.2.2 的 LG Optimus V。该项目有一个我正在使用 android ndk 构建的 jni 库。该应用程序在 Nexus-One 设备上安装和运行没有任何问题,但它在 LG 设备上崩溃并出现以下错误:

06-19 16:20:57.192: E/AndroidRuntime(3044): FATAL EXCEPTION: main
06-19 16:20:57.192: E/AndroidRuntime(3044): java.lang.ExceptionInInitializerError
06-19 16:20:57.192: E/AndroidRuntime(3044):     at java.lang.Class.newInstanceImpl(Native Method)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at java.lang.Class.newInstance(Class.java:1429)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at android.os.Looper.loop(Looper.java:123)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at android.app.ActivityThread.main(ActivityThread.java:4627)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at java.lang.reflect.Method.invokeNative(Native Method)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at java.lang.reflect.Method.invoke(Method.java:521)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:651)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at dalvik.system.NativeStart.main(Native Method)
06-19 16:20:57.192: E/AndroidRuntime(3044): Caused by: java.lang.UnsatisfiedLinkError: Library filters-jni not found
06-19 16:20:57.192: E/AndroidRuntime(3044):     at java.lang.Runtime.loadLibrary(Runtime.java:466)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at java.lang.System.loadLibrary(System.java:557)
06-19 16:20:57.192: E/AndroidRuntime(3044):     at com.test.MainActivity.<clinit>(MainActivity.java:427)
06-19 16:20:57.192: E/AndroidRuntime(3044):     ... 15 more

我的制作文件(Android.mk)看起来像:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE    := filters-jni
LOCAL_SRC_FILES := filters.c
LOCAL_CFLAGS := -DHAVE_CONFIG_H -DFPM_ARM -ffast-math -O3 -Wall
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -ldl
# for native audio
LOCAL_LDLIBS    += -lOpenSLES
# for logging
LOCAL_LDLIBS    += -llog
# for native asset manager
LOCAL_LDLIBS    += -landroid
LOCAL_STATIC_LIBRARIES := cpufeatures
include $(BUILD_SHARED_LIBRARY)
$(call import-module,cpufeatures)

我的应用程序制作文件只有一行

    APP_ABI := all

什么给出,我无法理解。谢谢大家的建议。

4

2 回答 2

2

OpenSLES 库仅适用于 Android 2.3。

有关可用于 Android 版本的库列表,请参阅docs/STABLE-APIS.htmlNDK 分发中的文件。

于 2012-06-19T21:36:06.410 回答
0

把它放在你的 Application.mk 文件中,看看会发生什么:

APP_ABI := armeabi armeabi-v7a x86

这为设备提供了三个 .so 以选择它喜欢的任何一个

于 2012-06-19T21:35:14.320 回答