如何调试Android上的C ++ code。通过使用Eclipse? [英] How to debug C++ code on Android by using Eclipse?

查看:173
本文介绍了如何调试Android上的C ++ code。通过使用Eclipse?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一些PC视频流处理器( C ++ ),现在我尝试在Android上导入相同的横平台部分。我中扮演足以与 NDK 键,大概了解了一下如何编译和整合 C code与Android (又名JNI)。

I wrote some video streamer (C++) on PC and now I try to to implement the same cross platform section on Android. I "played" enough with NDK and know a bit about how to compile and integrate C code with Android (aka JNI).

问题是,有时我的应用程序崩溃,正如你知道Android不点我在哪里,code失败(在C / C ++的一部分)。

The problem is that sometimes my application crashes and as you know Android doesn't point me where code failed (in C/C++ part).

视频流式code有很多的库和,可以说,我用这么离开日志开源部件 - 不是好主意。
我使用Eclipse,如何调试C ++ code还是Eclipse的有任何插件调试?

Video Streamer code have a lot of libraries and, lets say, open source parts I used so to leave logs - not good idea. I use Eclipse, how can I debug C++ code or does Eclipse have any plugins to debug?

非常感谢,

推荐答案

要记录的东西,看到它在通过Android的logcat的,我有一个简单的类:

To log stuff and see it in the logcat from Android, I have a simple class for that:

#ifndef LOG_H_
#define LOG_H_

#include <android/log.h>

#define LOGD(LOG_TAG, ...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define LOGI(LOG_TAG, ...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGV(LOG_TAG, ...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
#define LOGW(LOG_TAG, ...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
#define LOGE(LOG_TAG, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)

#endif /* LOG_H_ */

您可以用这种方式:

LOGI("YourClassTag","let's print some stuff: %i, %s", 4, "I'm a string");

要获得更多信息的一些崩溃,您可以尝试启用 JNICheck亚行的:

To get more info for some crashes, you may try to enable JNICheck with adb:

如果您有一个普通的设备,可以使用下面的命令:

If you have a regular device, you can use the following command:

adb shell setprop debug.checkjni 1

这不会影响到正在运行的应用程序,但是任何应用程序从启动
  点上会启用CheckJNI。 (该属性更改为任何其他
  值或简单地重新启动将禁用CheckJNI再次)。在这种情况下,
  你会看到这样的事情在你的logcat输出下一个时间
  应用程序启动:

This won’t affect already-running apps, but any app launched from that point on will have CheckJNI enabled. (Change the property to any other value or simply rebooting will disable CheckJNI again.) In this case, you’ll see something like this in your logcat output the next time an app starts:

ð晚启用CheckJNI

D Late-enabling CheckJNI

这篇关于如何调试Android上的C ++ code。通过使用Eclipse?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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