Android 原生代码调试 [英] Android Native Code Debugging

查看:22
本文介绍了Android 原生代码调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在eclipse中的android应用程序开发中的log-cat上获取本机c++程序的cout输出.

How can I get the cout output of the native c++ program on the log-cat in android application development in eclipse.

请有人在这里帮助我.

推荐答案

stdout/stderr 文件描述符被发送到 Android 应用中的 /dev/null.(Java 等效项 System.outSystem.err 被应用程序框架重定向到日志.)

The stdout/stderr file descriptors are sent to /dev/null in Android apps. (The Java equivalents, System.out and System.err, are redirected to the log by the app framework.)

Dalvik VM 包含一个 hack,可让您通过设置 log.redirect-stdio 属性在有根设备上查看 stdout/stderr.有关详细信息,请参阅此链接.它通过启动一个线程来工作,该线程从 stdio 文件描述符中读取数据并将数据复制到日志系统.

The Dalvik VM includes a hack that will let you see stdout/stderr on a rooted device by setting the log.redirect-stdio property. See this link for details. It works by starting a thread that reads from the stdio file descriptors and copies the data to the logging system.

对于新代码,直接使用 Android 日志调用要容易得多.当然,如果您要从其他地方导入库,那就有点困难了.如有必要,您可以复制 Dalvik 中的代码 和进入您的应用并让它做同样的事情.

For new code, it's much easier to use the Android log calls directly. If you're importing a library from elsewhere, of course, it's a bit harder. If necessary you could copy the code out of Dalvik and into your app and have it do the same thing.

这篇关于Android 原生代码调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆