Android原生code调试Android、code

2023-09-05 03:17:21 作者:ゞ活出尼玛的姿态

我怎样才能获得本地C ++程序的COUT输出上的日志,猫android应用开发在eclipse。

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

请人帮助我在这里。

推荐答案

在标准输出/标准错误文件描述符在Android应用程序发送到的/ dev / null的。 (Jav​​a的等价物,的System.out System.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虚拟机包括一个黑客工具,将让你看到标准输出/标准错误一个植根设备上通过设置 log.redirect-标准输入输出属性。请参见的详细信息,此链接。它通过启动一个线程读取从标准输入输出文件描述符,并将数据复制到日志记录系统。

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.

有关新的code,它更容易直接使用Android的日志调用。如果你从其他地方进口图书馆,当然,这是一个有点困难。如果有必要,你可以复制的code OUT的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.