C/C++ printfs - Where's it appears in a Android native code?

后端 未结 2 1593
夕颜
夕颜 2020-12-08 20:19

Since It\'s pretty hard to debug native android code, I\'m going to the \"printf trace\" approach.

So, my question is, in a native code, wheres the standards \"print

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 21:10

    Log to logcat.

    1) To invoke the logger in native code include the header and call _android_log_write(..).

    #include 
    
    __android_log_write(ANDROID_LOG_INFO, "tag here", "message here");
    

    2) In your Android.mk file include the log lib like this.

    LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog 
    

提交回复
热议问题