Android 获取';LOGE';未在NDK中的此作用域错误中声明
当我试图在我的机器中编译示例本机(cpp)代码时,我遇到了这些错误。我正试图在cygwin的NDK的帮助下编译本机代码 我得到以下错误,我尝试添加LDFLAGS,但仍然得到相同的错误 本地_LDLIBS:=-llogAndroid 获取';LOGE';未在NDK中的此作用域错误中声明,android,android-ndk,android-ndk-r5,Android,Android Ndk,Android Ndk R5,当我试图在我的机器中编译示例本机(cpp)代码时,我遇到了这些错误。我正试图在cygwin的NDK的帮助下编译本机代码 我得到以下错误,我尝试添加LDFLAGS,但仍然得到相同的错误 本地_LDLIBS:=-llog sh-4.1$ /cygdrive/c/Android/android-ndk-r6/ndk-build Compile++ thumb : JNIExampleInterface <= JNIExampleInterface.cpp D:/EclipseWorks
sh-4.1$ /cygdrive/c/Android/android-ndk-r6/ndk-build
Compile++ thumb : JNIExampleInterface <= JNIExampleInterface.cpp
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:5:44: error: android_runtime/AndroidRuntime.h: No such file or directory
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp: In function 'void callback_handler(char*)':
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:36: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:51: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:59: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp: In function 'void Java_com_nativeexample_JNIExampleInteace_callVoid(JNIEnv*, _jclass*)':
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:88: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp: In function '_jobject* Java_com_nativeexample_JNIExamplnterface_getNewData(JNIEnv*, _jclass*, jint, _jstring*)':
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:103: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:110: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:117: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp: In function '_jstring* Java_com_nativeexample_JNIExamplnterface_getStringInData(JNIEnv*, _jclass*, _jobject*)':
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:135: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:142: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp: In function 'void initClassHelper(JNIEnv*, const char*,jobject**)':
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:163: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:170: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:177: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp: In function 'jint JNI_OnLoad(JavaVM*, void*)':
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:193: error: 'LOGI' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:195: error: 'LOGE' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:221: error: 'android' has not been declared
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:222: error: 'NELEM' was not declared in this scope
D:/EclipseWorkspace/NativeExample/jni/JNIExampleInterface.cpp:223: error: 'LOGE' was not declared in this scope
make: *** [/cygdrive/d/EclipseWorkspace/NativeExample/obj/local/armeabi/objs/JNIExampleInterface/JNIExampleInterface.o
Error 1
sh-4.1$
sh-4.1$/cygdrive/c/Android/Android-ndk-r6/ndk build
Compile++thumb:JNIExampleInterface通过使用以下声明,我只能解决LOGE错误:
#define LOG_TAG "libJNIExInterface"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
在“android_日志…”之前出现双倍欠分
另一个错误是“NELEM”在android运行时注册本机函数,这不是必需的,但只有在您拥有完整的android源代码的情况下才能执行,当您将此应用程序与android源代码一起编译时,否则这是不可能的)
因此,当您没有完整的Android源代码时,Android运行时注册是不可能的,不管怎样,我的应用程序也可以正常运行。如果有人仍然存在此问题:
日志宏已被重命名,现在是ALOGE
。我可以通过将此代码添加到顶部“#define LOG_TAG”libjniexample interface”#define LOGI(…)android_LOG_print(android_LOG_INFO,LOG_TAG,_VA_ARGS)#define LOGE(…)android_LOG_LOG_print(android_LOG_error,LOG_TAG,_VA_ARGS)#但仍然无法解决AndroidRuntime错误(NELEM),但发现它是框架的一部分(头文件)。注册我们的功能还有其他方法吗?