【发布时间】:2015-08-24 02:45:16
【问题描述】:
我在使用 android-ndk-r10e 编译我的 jni 代码时遇到问题。
在 jni 文件夹内有主 c 代码文件 hello.c,然后是另一个文件夹 includeLocal,其中有 com_MyPackage_Hello.h 文件里面。以前的 ndk 版本可以正常编译,但现在出现此错误:
Error:error: unknown type name 'jobjectArrayJNICALL'
JNIEXPORT jobjectArrayJNICALL Java_com_MyPackage_Hello_hello(
^
Error:error: conflicting types for 'Java_com_MyPackage_Hello_hello'
JNIEXPORT jobjectArrayJNICALL Java_com_MyPackage_Hello_hello(
^
Information:(Unknown) In file included
jni/includeLocal/Java_com_MyPackage_Hello.h:22:9: note: previous declaration of 'Java_com_MyPackage_Hello_hello' was here
Java_com_MyPackage_Hello_hello(JNIEnv *, jobject, jbyteArray, jint, jint);
^
jni/hello.c: In function 'Java_com_MyPackage_Hello_hello':
Warning:warning: return makes integer from pointer without a cast [enabled by default]
return NULL; /* exception already thrown */
^
Warning:warning: return makes integer from pointer without a cast [enabled by default]
return NULL;
^
Warning:warning: return makes integer from pointer without a cast [enabled by default]
return ret;
^
任何想法如何解决这个问题?我不是很热衷于 ndk 的东西。
下面是h。文件也是如此
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_MyPackage_Hello */
#ifndef _Included_com_MyPackage_Hello
#define _Included_com_MyPackage_Hello
#ifdef __cplusplus
extern "C" {
#endif
#undef com_MyPackage_Hello_MIN_PRIORITY
#define com_MyPackage_Hello_MIN_PRIORITY 1L
#undef com_MyPackage_Hello_NORM_PRIORITY
#define com_MyPackage_Hello_NORM_PRIORITY 5L
#undef com_MyPackage_Hello_MAX_PRIORITY
#define com_MyPackage_Hello_MAX_PRIORITY 10L
/*
* Class: com_MyPackage_Hello
* Method: hello
* Signature: ([BI)[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL
Java_com_MyPackage_Hello_hello(JNIEnv *, jobject, jbyteArray, jint, jint);
#ifdef __cplusplus
}
#endif
#endif
【问题讨论】:
-
您不小心在
jobjectArray和JNICALL之间遗漏了一个空格? -
@immibis 我不相信你是对的。当我进行自动格式化时,这是 android studio 的错。新的 NDK 支持仍然很糟糕。
标签: java android c++ c android-ndk