Android Studio:无法解析相应的JNI功能

时间:2016-01-29 02:50:34

标签: android android-studio android-ndk java-native-interface fft

我已阅读This question this question,但我仍然无法使其发挥作用。

问题是一样的,我尝试在Android Studio 1.5.1中使用FFTS,生成了这样的文件,但Android Studio无法找到原生方法,UnsatisflyLinkError是抛出。

编辑: 我发现问题是我的函数没有编译成so文件。

cpu_check.c

#ifdef ANDROID
#include <jni.h>
#include <cpu-features.h>

JNIEXPORT jboolean JNICALL Java_nz_ac_waikato_ffts_FFTS_has_neon
(JNIEnv *env, jclass jc)
{
    if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
        (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
    return JNI_TRUE;

    // use NEON-optimized routines

    else
    return JNI_FALSE;

    // use non-NEON fallback routines instead
}
#endif

当我查看已编译的libcpucheck.so时,它没有~has_neon函数。但它的大小为16K,有一些功能,如CPU检查。这是我的 Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := cpucheck
LOCAL_SRC_FILES := cpu_check.c

LOCAL_STATIC_LIBRARIES := cpufeatures
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := ffts
LOCAL_C_INCLUDES := jni/include jni/src
LOCAL_CFLAGS := -DHAVE_DECL_MEMALIGN -std=c99 \
    -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
LOCAL_SRC_FILES := \
    ffts_jni.c \
    src/ffts.c \
    src/ffts_nd.c \
    src/ffts_real.c \
    src/ffts_real_nd.c \
    src/ffts_small.c \
    src/patterns.c
LOCAL_LDLIBS := -llog 

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_MODULE := ffts-vfp
LOCAL_CFLAGS += -DHAVE_VFP
LOCAL_SRC_FILES += \
    src/codegen.c \
    src/vfp.s
endif

include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := ffts
LOCAL_C_INCLUDES := jni/include jni/src
LOCAL_CFLAGS := -DHAVE_DECL_MEMALIGN -std=c99 \
    -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
LOCAL_SRC_FILES := \
    ffts_jni.c \
    src/ffts.c \
    src/ffts_nd.c \
    src/ffts_real.c \
    src/ffts_real_nd.c \
    src/ffts_small.c \
    src/patterns.c
LOCAL_LDLIBS := -llog 

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_MODULE := ffts-neon
LOCAL_CFLAGS += -DHAVE_NEON
LOCAL_ARM_NEON := true
LOCAL_SRC_FILES += \
    src/codegen.c \
    src/neon.s
endif

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/cpufeatures)

0 个答案:

没有答案