在 Android 上的 Eclipse 中调试有什么问题? [英] What's wrong with debugging in Eclipse on Android?

查看:18
本文介绍了在 Android 上的 Eclipse 中调试有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
看似无用的Android调试环境

我显然被 Visual Studio 宠坏了,因为虽然我只是在学习 Android 和 Eclipse 环境,但在 Eclipse 中调试应用程序正在严重损害进一步的开发.

I've obviously been spoiled by Visual Studio, because although I'm just learning Android and the Eclipse environment, debugging apps in Eclipse is becoming a serious detriment to further development.

例如,Eclipse 会很好地编译这个除以零:

For example, Eclipse will compile this divide by zero just fine:

public class Lesson2Main extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate (savedInstanceState);

        int i = 1 / 0;

        TextView tv = new TextView (this);
        tv.setText ("Hello, Android!");
        setContentView (tv);
    }
}

然后,当它在调试器下执行它时,我会得到一个无用的调试信息的全屏,其中实际上没有将我指向包含错误的特定行.

And then, when it executes it under the debugger, I will get a full screen of useless debug info, non of which actually points me to the specific line containing the error.

异常 ('e') 信息树中的 stackTrace 为空,它只是声明一条消息,说明ArithmeticException".(太好了,你给我指出你找到它的方向如何!?)

The stackTrace is null within the exception ('e') info tree, and it simply states a message stating 'ArithmeticException'. (that's nice, how about you point me in the direction of where you found it!?)

我已经看遍了整个屏幕,但对这个 IDE 无法正确处理感到困惑.使用 Eclipse 进行开发是否会让每个人都回到 1991 年使用 printf() 喜欢在每个时间间隔记录然后跟踪错误?认真的.

I've looked all over the screen and am baffled that this IDE can't get this right. Does developing with Eclipse resort everyone back to 1991 with printf() like logging at every interval then to track down bugs? Seriously.

是否有我缺少的配置或插件可以帮助解决这个问题?

Is there a configuration or plug-in that I'm missing to help with this?

我还没有用 XCode 测试过这个案例,但如果是 iPhone 开发者.IDE 处理这个更像 Visual Studio,难怪 Android 市场的应用程序如此之少.

I haven't tested this case with XCode, but if the iPhone dev. IDE handles this more like Visual Studio, then no wonder the Android marketplace has so few apps.

我对 Android 感到很兴奋,但 Eclipse 似乎阻碍了我的发展.

I'm excited about Android, but it seems that Eclipse is getting in the way.

推荐答案

是的,您已经错过了一个非常重要的 Eclipse 插件LogCat".它会捕获您的 Android 程序提供的所有调试日志,无论它是在模拟器上运行还是在真实手机上运行.后者显然需要将手机插入电脑,不太明显的是,在应用程序->开发->启用USB调试中的设置被启用.

Yes, you've missed one of the very important plug-ins for Eclipse called "LogCat". It catches all the debugging logs that your Android program gives, whether it's running on the Emulator or a real phone. The latter obviously requires that the phone be plugged in to the computer, and less-obviously, the setting in Application -> Development -> Enable USB Debugging be enabled.

LogCat 消息为您提供导致错误的原因的完整分类,包括行号.要在 Eclipse 中打开 LogCat,请转到 Window -> Show View -> Other -> Android(列表中的文件夹之一)-> LogCat.然后将 LogCat 窗口停靠在您可以轻松看到的位置,Eclipse 将记住该位置并在您下次启动时再次打开它.

The LogCat messages give you the full breakdown of what caused the error, including the line number. To open LogCat in Eclipse, go to Window -> Show View -> Other -> Android (one of the folders in the list) -> LogCat. Then dock the LogCat window somewhere where you can see it easily, and Eclipse will remember that location and open it up again next time your start it.

(有时 LogCat 和模拟器会相互断开连接.解决这个问题的简单方法就是关闭 Eclipse 和模拟器,然后重新启动它们.)

(Sometimes LogCat and the Emulator get disconnected from each other. The simple way to fix that is just to close Eclipse and the emulator, then restart them both.)

这篇关于在 Android 上的 Eclipse 中调试有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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