我在网上找了一些资料编写了一个jni库,用来显示yuv数据,里面用到了一些android源码的库文件如下:
#include <assert.h>
#include <JNIHelp.h>
#include <utils/Log.h>
#include <gui/Surface.h>
#include <cutils/properties.h>
#include <ui/GraphicBufferMapper.h>
#include <media/stagefright/foundation/ADebug.h>
#include <android_runtime/android_view_Surface.h>
所以对Android.mk做了修改,包含Android源码 Android.mk内容如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := showYUV
MY_ANDROID_SOURCE = D:/Android/java_software/android_4.4
MY_ANDROID_SYSLIB = $(MY_ANDROID_SOURCE)/out/target/product/generic/system/lib
MY_FILES_PATH := $(LOCAL_PATH)
MY_FILES_SUFFIX := %.cpp %.c
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
MY_ALL_FILES := $(foreach src_path,$(MY_FILES_PATH), $(call rwildcard,$(src_path),*.*))
MY_ALL_FILES := $(MY_ALL_FILES:$(MY_CPP_PATH)/./%=$(MY_CPP_PATH)%)
MY_SRC_LIST := $(filter $(MY_FILES_SUFFIX),$(MY_ALL_FILES))
MY_SRC_LIST := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
MY_ALL_DIRS := $(dir $(foreach src_path,$(MY_FILES_PATH), $(call rwildcard,$(src_path),*/)))
MY_ALL_DIRS := $(call uniq,$(MY_ALL_DIRS))
LOCAL_SRC_FILES := $(MY_SRC_LIST)
LOCAL_C_INCLUDES := $(MY_ALL_DIRS)
LOCAL_CPPFLAGS += -fexceptions -DXLOCALE_NOT_USED=1 -DNULL=0 -DNO_SSTREAM=1 -UIP_ADD_SOURCE_MEMBERSHIP
LOCAL_STATIC_LIBRARIES := \
libstagefright_color_conversion\
LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
libbinder \
libui \
libgui \
libstagefright\
libstagefright_foundation
LOCAL_C_INCLUDES += \
$(MY_ANDROID_SOURCE)/external/opencore/codecs_v2/video/mfc_c110/include \
$(MY_ANDROID_SOURCE)/libnativehelper/include/nativehelper \
$(MY_ANDROID_SOURCE)/frameworks/native/include \
$(MY_ANDROID_SOURCE)/frameworks/av/include \
$(MY_ANDROID_SOURCE)/frameworks/base/include \
$(MY_ANDROID_SOURCE)/hardware/libhardware/include \
$(MY_ANDROID_SOURCE)/system/core/include
# for logging
LOCAL_LDLIBS += -llog
LOCAL_LDLIBS += -landroid -lstdc++
LOCAL_LDFLAGS += -fuse-ld=bfd
//LOCAL_CXXFLAGS := -DHAVE_PTHREADS
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
include $(BUILD_SHARED_LIBRARY)
$(call import-module,cpufeatures)
$(warning $(LOCAL_SRC_FILES))
$(warning $(MY_INCLUDE_LIST))
编译通过生成so文件,但是在运行加载so文件时报错 java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZNK7android7RefBase9decStrongEPKv" 查了一下有的说是因为android ndk版本太高导致的
我的Android ndk版本是 ndk-r10 Android源码版本是4.4的 Android软件要多平台支持 从4.0~4.4的 所以我想向各位质询一下这个问题怎么解决呢。
------解决思路----------------------
_ZNK7android7RefBase9decStrongEPKv 这个是用到的函数是在2.2下面才可以使用,在2.2之后播放框架修改了,无法找到这个函数了。
------解决思路----------------------
提示很明确。用android NDK r8 或r9重编一下试试!