有任何简单的登录Android NDK代码的方法吗? [英] Any simple way to log in Android NDK code?
问题描述
我正在寻找一种使用Eclipse在Android NDK应用程序中轻松调试C代码的方法.我已经阅读了使用gdb或类似工具调试应用程序的方法,但是我想要的是以某种方式将消息推送到Eclipse的方法.
I'm looking for a way to easily debug C code in an Android NDK application using Eclipse. I've read ways to debug the app using gdb or something similar but what I want is a way to push messages to Eclipse somehow.
我正在寻找一种简单的解决方案,就像在C语言中使用打印功能并在DDMS日志或任何类似内容中看到它一样.有没有人有这样做的经验?
I'm looking for a solution that's as simple as using a print function in C and seeing it in the DDMS Log or anything similar. Does anyone have any experience doing this?
推荐答案
您可以使用Android日志记录功能:
You can use the Android logging facilities:
#include <android/log.h>
#define APPNAME "MyApp"
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "The value of 1 + 1 is %d", 1+1);
确保还链接到Android.mk文件中的日志记录库:
Make sure you also link against the logging library, in your Android.mk file:
LOCAL_LDLIBS := -llog
这篇关于有任何简单的登录Android NDK代码的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!