3

我遇到了一个错误,使用jni ...我在android活动类中有一个简单的本机方法并为此创建了头文件并为此实现了c文件...找不到错误请帮助

这是我拥有的文件

活动

static{
        System.loadLibrary("fluidsynth");
    }



    private  native String textOverjni();

头文件

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_example_fluidsynthtest_MyFluidSynthO */

#ifndef _Included_com_example_fluidsynthtest_MyFluidSynthO
#define _Included_com_example_fluidsynthtest_MyFluidSynthO
#ifdef __cplusplus
extern "C" {
#endif
#undef com_example_fluidsynthtest_MyFluidSynthO_MODE_PRIVATE
#define com_example_fluidsynthtest_MyFluidSynthO_MODE_PRIVATE 0L
#undef com_example_fluidsynthtest_MyFluidSynthO_MODE_WORLD_READABLE
#define com_example_fluidsynthtest_MyFluidSynthO_MODE_WORLD_READABLE 1L
#undef com_example_fluidsynthtest_MyFluidSynthO_MODE_WORLD_WRITEABLE
#define com_example_fluidsynthtest_MyFluidSynthO_MODE_WORLD_WRITEABLE 2L
#undef com_example_fluidsynthtest_MyFluidSynthO_MODE_APPEND
#define com_example_fluidsynthtest_MyFluidSynthO_MODE_APPEND 32768L
#undef com_example_fluidsynthtest_MyFluidSynthO_BIND_AUTO_CREATE
#define com_example_fluidsynthtest_MyFluidSynthO_BIND_AUTO_CREATE 1L
#undef com_example_fluidsynthtest_MyFluidSynthO_BIND_DEBUG_UNBIND
#define com_example_fluidsynthtest_MyFluidSynthO_BIND_DEBUG_UNBIND 2L
#undef com_example_fluidsynthtest_MyFluidSynthO_BIND_NOT_FOREGROUND
#define com_example_fluidsynthtest_MyFluidSynthO_BIND_NOT_FOREGROUND 4L
#undef com_example_fluidsynthtest_MyFluidSynthO_CONTEXT_INCLUDE_CODE
#define com_example_fluidsynthtest_MyFluidSynthO_CONTEXT_INCLUDE_CODE 1L
#undef com_example_fluidsynthtest_MyFluidSynthO_CONTEXT_IGNORE_SECURITY
#define com_example_fluidsynthtest_MyFluidSynthO_CONTEXT_IGNORE_SECURITY 2L
#undef com_example_fluidsynthtest_MyFluidSynthO_CONTEXT_RESTRICTED
#define com_example_fluidsynthtest_MyFluidSynthO_CONTEXT_RESTRICTED 4L
#undef com_example_fluidsynthtest_MyFluidSynthO_RESULT_CANCELED
#define com_example_fluidsynthtest_MyFluidSynthO_RESULT_CANCELED 0L
#undef com_example_fluidsynthtest_MyFluidSynthO_RESULT_OK
#define com_example_fluidsynthtest_MyFluidSynthO_RESULT_OK -1L
#undef com_example_fluidsynthtest_MyFluidSynthO_RESULT_FIRST_USER
#define com_example_fluidsynthtest_MyFluidSynthO_RESULT_FIRST_USER 1L
#undef com_example_fluidsynthtest_MyFluidSynthO_DEFAULT_KEYS_DISABLE
#define com_example_fluidsynthtest_MyFluidSynthO_DEFAULT_KEYS_DISABLE 0L
#undef com_example_fluidsynthtest_MyFluidSynthO_DEFAULT_KEYS_DIALER
#define com_example_fluidsynthtest_MyFluidSynthO_DEFAULT_KEYS_DIALER 1L
#undef com_example_fluidsynthtest_MyFluidSynthO_DEFAULT_KEYS_SHORTCUT
#define com_example_fluidsynthtest_MyFluidSynthO_DEFAULT_KEYS_SHORTCUT 2L
#undef com_example_fluidsynthtest_MyFluidSynthO_DEFAULT_KEYS_SEARCH_LOCAL
#define com_example_fluidsynthtest_MyFluidSynthO_DEFAULT_KEYS_SEARCH_LOCAL 3L
#undef com_example_fluidsynthtest_MyFluidSynthO_DEFAULT_KEYS_SEARCH_GLOBAL
#define com_example_fluidsynthtest_MyFluidSynthO_DEFAULT_KEYS_SEARCH_GLOBAL 4L
/*
 * Class:     com_example_fluidsynthtest_MyFluidSynthO
 * Method:    textOverjni
 * Signature: ()Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_com_example_fluidsynthtest_MyFluidSynthO_textOverjni
  (JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif

C 文件

#include <jni.h>
#include <string.h>
#include <MyFluidSynthO.h>


JNIEXPORT jstring  Java_com_example_fluidsynthtest_MyFluidSynthO_textOverjni
  (JNIEnv* env, jobject obj){
    return (*env)->NewStringUTF(env, "Hello Worlddd from MyFluidSynth1 !");
}

安卓.mk

LOCAL_PATH := $(call my-dir)

include  $(CLEAR_VARS)

LOCAL_MODULE   := fluidsynth
#LOCAL_C_INCLUDES +:= $(LOCAL_PATH)/include\
$(LOCAL_PATH)/include/fluidsynth

LOCAL_SRC_FILES +:= \
    MyFluidSynthO.c
#LOCAL_LDLIBS := -llog
include  $(BUILD_SHARED_LIBRARY)

#include $(CLEAR_VARS)

#include $(BUILD_SHARED_LIBRARY)
4

2 回答 2

2

对于构建 Android NDK 时出现的“未找到实现”问题,您可以查看以下链接,这些链接解释了这些问题的原因和解决方案。

Android NDK C++ JNI(没有找到原生的实现......)

android ndk jni No implementation found 错误

调用 C 函数时出现“No implementation found for native”错误 - Android NDK - Eclipse

于 2013-03-14T05:50:32.537 回答
-4

通过ndk_build再次构建.so文件

于 2015-05-22T13:39:23.980 回答