C/C++ printfs - 它出现在Android本机代码中的哪个位置?

Mar*_*los 22 debugging android android-ndk

由于调试原生android代码非常困难,我将采用"printf trace"方法.

所以,我的问题是,在本机代码中,运行Android应用程序时会出现"printf("something")"标准吗?

Rya*_*ves 41

登录到logcat.

1)在本机代码中调用记录器包括头并调用_android_log_write(..).

#include <android/log.h>

__android_log_write(ANDROID_LOG_INFO, "tag here", "message here");
Run Code Online (Sandbox Code Playgroud)

2)在你的Android.mk文件中包含这样的日志库.

LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog 
Run Code Online (Sandbox Code Playgroud)

  • (SYSROOT)/usr/lib 是什么? (2认同)