登录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屋!