我看到一些设备的崩溃报告(所有arm64 acrhitecture)看起来像这样:
Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZNK6TagLib4File10propertiesEv" referenced by "/data/app/com.app.my/lib/arm64/libtaglib-wrapper.so"...
at java.lang.Runtime.loadLibrary(Runtime.java:372)
at java.lang.System.loadLibrary(System.java:988)
at helpers.TagReaderService.(SourceFile)
受影响的操作系统版本为5.1。由于我读错了同一个问题(但与系统依赖关系相关),因为错误的APP_PLATFORM
,我再次检查它是否正确,实际上我定位android-16
。
我应该提一下,该符号在另一个共享库taglib.so
中声明,然后链接到第二个taglib-wrapper.so
。
我还执行了objdump
两者
taglib.so:
0000000000140590 g DF .text 000000000000004c Base TagLib::File::properties() const
和taglib-wrapper.so:
0000000000000000 DF *UND* 0000000000000000 TagLib::File::properties() const
因此符号会正确传播到taglib-wrapper.so
库。
我个人使用arm64设备并没有问题。
我还检查了Application.mk
没有被忽略添加随机字符并执行Gradle构建。在gradle.build文件中没有相关的NDK-config代码。
您可以在Git repo上提交cpp
代码。
Application.mk
APP_STL := c++_shared
APP_ABI := arm64-v8a x86 armeabi-v7a
APP_PLATFORM := android-16
APP_CPPFLAGS += -frtti -fexceptions
Android.mk
LOCAL_PATH:= $(call my-dir)
# ======= TagLib engine ============================
include $(CLEAR_VARS)
LOCAL_MODULE := taglib
LOCAL_C_INCLUDES := $(LOCAL_PATH)/taglib \
$(LOCAL_PATH)/taglib/ape \
$(LOCAL_PATH)/taglib/asf \
$(LOCAL_PATH)/taglib/dsf \
$(LOCAL_PATH)/taglib/ebml \
$(LOCAL_PATH)/taglib/ebml/matroska \
$(LOCAL_PATH)/taglib/flac \
$(LOCAL_PATH)/taglib/it \
$(LOCAL_PATH)/taglib/mod \
$(LOCAL_PATH)/taglib/mp4 \
$(LOCAL_PATH)/taglib/mpc \
$(LOCAL_PATH)/taglib/mpeg \
$(LOCAL_PATH)/taglib/mpeg/id3v1 \
$(LOCAL_PATH)/taglib/mpeg/id3v2 \
$(LOCAL_PATH)/taglib/mpeg/id3v2/frames \
$(LOCAL_PATH)/taglib/ogg \
$(LOCAL_PATH)/taglib/ogg/flac \
$(LOCAL_PATH)/taglib/ogg/opus \
$(LOCAL_PATH)/taglib/ogg/speex \
$(LOCAL_PATH)/taglib/ogg/vorbis \
$(LOCAL_PATH)/taglib/riff \
$(LOCAL_PATH)/taglib/riff/aiff \
$(LOCAL_PATH)/taglib/riff/wav \
$(LOCAL_PATH)/taglib/s3m \
$(LOCAL_PATH)/taglib/toolkit \
$(LOCAL_PATH)/taglib/trueaudio \
$(LOCAL_PATH)/taglib/wavpack \
$(LOCAL_PATH)/taglib/xm
FILE_LIST := $(wildcard $(LOCAL_PATH)/taglib/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/taglib/**/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/taglib/**/**/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/taglib/**/**/**/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_EXPORT_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
# ======= TagLib wrapper ===========================
include $(CLEAR_VARS)
LOCAL_MODULE := taglib-wrapper
LOCAL_C_INCLUDES := $(LOCAL_PATH)/taglib \
$(LOCAL_PATH)/taglib/ape \
$(LOCAL_PATH)/taglib/asf \
$(LOCAL_PATH)/taglib/dsf \
$(LOCAL_PATH)/taglib/ebml \
$(LOCAL_PATH)/taglib/ebml/matroska \
$(LOCAL_PATH)/taglib/flac \
$(LOCAL_PATH)/taglib/it \
$(LOCAL_PATH)/taglib/mod \
$(LOCAL_PATH)/taglib/mp4 \
$(LOCAL_PATH)/taglib/mpc \
$(LOCAL_PATH)/taglib/mpeg \
$(LOCAL_PATH)/taglib/mpeg/id3v1 \
$(LOCAL_PATH)/taglib/mpeg/id3v2 \
$(LOCAL_PATH)/taglib/mpeg/id3v2/frames \
$(LOCAL_PATH)/taglib/ogg \
$(LOCAL_PATH)/taglib/ogg/flac \
$(LOCAL_PATH)/taglib/ogg/opus \
$(LOCAL_PATH)/taglib/ogg/speex \
$(LOCAL_PATH)/taglib/ogg/vorbis \
$(LOCAL_PATH)/taglib/riff \
$(LOCAL_PATH)/taglib/riff/aiff \
$(LOCAL_PATH)/taglib/riff/wav \
$(LOCAL_PATH)/taglib/s3m \
$(LOCAL_PATH)/taglib/toolkit \
$(LOCAL_PATH)/taglib/trueaudio \
$(LOCAL_PATH)/taglib/wavpack \
$(LOCAL_PATH)/taglib/xm
LOCAL_SRC_FILES := taglib.cpp
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES := taglib
include $(BUILD_SHARED_LIBRARY)
更新 我在一个独特的共享库中合并了这两个库。现在,同一台设备(魅族MX4)在该库的第一次JNI调用时崩溃:
java.lang.UnsatisfiedLinkError: No implementation found for void helpers.IOWrapper.initialize() (tried Java_helpers_IOWrapper_initialize and Java_helpers_IOWrapper_initialize__) at helpers.IOWrapper.initialize(Native Method) at helpers.IOWrapper.read(SourceFile:136) at helpers.IOWrapper.read(SourceFile:123) at helpers.TagReaderService$a.run(SourceFile:58) at java.lang.Thread.run(Thread.java:818)
它有可能是唯一崩溃的设备吗?我正在加载库,因为静态声明是同一个Java类。我使用extern C声明来包装cpp文件。也许是因为我错过了JNIEXPORT和JNICALL?