223*_*112 13 android android-ndk logcat android-logcat
如何从Android(NDK)中的Native代码中写入日志?有哪些选择?例如,可以从NDK内部使用logcat来写日志吗?或者因为它在Android中更高级别,它无法从NDK访问?
目前我只知道从C代码编写时间:
millis = System.currentTimeMillis();
并且具有将此时间加上任何消息写入自定义日志文件的功能.
Ank*_*ani 29
您可以使用Android日志记录
#include <android/log.h>
#define APPNAME "MyApp"
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "My Log");
Run Code Online (Sandbox Code Playgroud)
另外,请确保您还链接到Android.mk文件中的日志库:
LOCAL_LDLIBS := -llog
Run Code Online (Sandbox Code Playgroud)
它已经以任何简单或简单的方式讨论调试Android NDK代码?
ATu*_*rMe 17
如果您使用的是使用CMake 的较新的Android Studio版本(2.2+),那么当您生成具有C++支持的新项目时,您会发现以下内容会自动添加到您的CMakeLists.txt文件中:
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
Run Code Online (Sandbox Code Playgroud)
和
target_link_libraries( # Specifies the target library.
your-lib1
your-lib2
...
# Links the target library to the log library
# included in the NDK.
${log-lib} )
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17512 次 |
| 最近记录: |