javah jni generated header has syntax error - Android NDK - eclipse

戏子无情 提交于 2019-12-23 06:22:54

问题


Android NDK, I used the following command to generate the jni header,

C:\eclipse_workspace\C_Google_FaceDetect\bin>javah -jni -verbose -classpath C:\Android_SDK\platforms\android-10;C:\eclipse_workspace\C_Google_FaceDetect\src;. -d C:\eclipse_workspace\C_Google_FaceDetect\jni c.google.facedetect.FaceDetect

The problem is even though I set everything well, I'm getting the following error

No implementation found for native Lc/google/facedetect/FaceDetect;.decodeYUV([I[BII)V

threadid=1:thread exiting with uncaught exception (group=0x40018578)

FATAL EXCEPTION: main java.lang.UnsatisfiedLinkError: decodeYUV

I tried looking for what's wrong, and I found that in the c_google_facedetect_FaceDetect.h jni header file, I have a syntax error actually (even though it's generated)

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

#ifndef _Included_c_google_facedetect_FaceDetect
#define _Included_c_google_facedetect_FaceDetect
#ifdef __cplusplus extern "C" {
#endif
#undef c_google_facedetect_FaceDetect_CAMERA_WIDTH
#define c_google_facedetect_FaceDetect_CAMERA_WIDTH 480L
#undef c_google_facedetect_FaceDetect_CAMERA_HEIGHT
#define c_google_facedetect_FaceDetect_CAMERA_HEIGHT 320L
/*
* Class:     c_google_facedetect_FaceDetect
* Method:    decodeYUV
* Signature: ([I[BII)V
*/

JNIEXPORT void JNICALL Java_c_google_facedetect_FaceDetect_decodeYUV(JNIEnv *, jobject, jintArray, jbyteArray, jint, jint);

#ifdef __cplusplus }
#endif
#endif

The "JNIEXPORT void JNICALL ...." line has a syntax error, maybe that's what causing all the errors ?

My Android.mk file is as follows:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := face-detect

LOCAL_SRC_FILES := face-detect.c

include $(BUILD_SHARED_LIBRARY)

UPDATE My one and only java file is called FaceDetect.java and includes the following code

public class FaceDetect extends Activity implements SurfaceHolder.Callback, Camera.PreviewCallback
{
static
    {
        Log.d("mytag", "before_lib");
        System.loadLibrary("face-detect");
        Log.d("mytag", "after_lib");
    }
public static native void decodeYUV(int[] out, byte[] fg, int width, int height);
}

Also, Eclipse doesn't say what the syntax error is, it only underlines the JNIExport line and says syntax error

Another UPDATE to answer the question I have indeed checked that the library is being loaded, here is the logcat

07-16 13:31:43.257: D/mytag(25188): before_lib
07-16 13:31:43.281: D/dalvikvm(25188): Trying to load lib /data/data/c.google.facedetect/lib/libface-detect.so 0x40517808
07-16 13:31:43.281: D/dalvikvm(25188): Added shared lib /data/data/c.google.facedetect/lib/libface-detect.so 0x40517808
07-16 13:31:43.281: D/dalvikvm(25188): No JNI_OnLoad found in /data/data/c.google.facedetect/lib/libface-detect.so 0x40517808, skipping init
07-16 13:31:43.281: D/mytag(25188): after_lib


回答1:


There is no syntax error. Check that you are loading your native library and that it has loaded successfuly.



来源:https://stackoverflow.com/questions/11504155/javah-jni-generated-header-has-syntax-error-android-ndk-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!