为什么我不能看到我的logcat中print语句? [英] Why can't I see my print statements in Logcat?

查看:268
本文介绍了为什么我不能看到我的logcat中print语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图调试code对我的第一个Android程序。我开始使用常规的println,它在早期主要(的onCreate)方法有效,显示LogCat中的结果。然而,这似乎并没有下文的工作,所以后来我开始尝试Log.i / Log.d制定出没有sucess。基本上,我想看看如果程序实际运行下面的方法 - 虽然没有打印语句是在LogCat中产生的,我觉得code为实际运行,当我打新或退出按钮我的应用程序,它似乎FO在case语句中的正确位置和运行完成();

在获得一些打印到LogCat中会真的AP preciated任何帮助,所以我可以看到发生了什么事情。

感谢您

埃德瑞安

 公共无效的onClick(最终查看V){        的System.out.println(在这里,在 - 的onClick);
        开关(v.getId()){
        案例R.id.about_button:
           的System.out.println(在这里,在 - onClick1);
           意图I =新意图(这一点,About.class);
           startActivity(ⅰ);
           打破;
        案例R.id.new_button:
            的System.out.println(在这里,在 - onClick2);
            完();
           // openNewGameDialog();
           打破;
        案例R.id.exit_button:
            Log.i(onDisabled,信息);
            Log.d(TAGonDisabled);
            的System.out.println(在这里,在 - onClick3);
           完();
           打破;
        }
     }
} //结束类


解决方案

我在使用Eclipse中LogCat中经历了这一点。
发生这种情况时,该设备脱落或失去焦点,或当你使用2个或更多不同的设备/仿真器调试。

请尝试以下操作:


  1. 转至DDMS视角,双击你调试或至少是设备的应用程序。您应该看到LogCat中标签洪水与新的消息。

  2. 除非你与目前的工作之一卸下所有设备。

  3. 尝试仅仅使用日志。*函数一次。

  4. 将LogCat中过滤器来调试或详细。

I trying to debug code on my first Android program. I started using the regular println and it worked in the earlier main(onCreate) method, showing the results in LogCat. However, it doesn't seem to work below, so then I started trying to work out Log.i/Log.d to no sucess. I'm basically trying to see if the program actually runs the below method - although no print statements are produced in the LogCat, I think the code is actually running as when I hit the "new" or "exit"button on my app, it seems to fo to the correct place in the case statement and runs finish();

Any help with would be really appreciated in getting something printed to LogCat, so I can see what's going on.

Thank you

Ed Ryan


 public void onClick(final View v) {

        System.out.println("Here in  - onClick");
        switch (v.getId()) {
        case R.id.about_button:
           System.out.println("Here in  - onClick1");
           Intent i = new Intent(this, About.class);
           startActivity(i);
           break;
        case R.id.new_button:
            System.out.println("Here in  - onClick2");
            finish();
           //openNewGameDialog();
           break;
        case R.id.exit_button:
            Log.i("onDisabled","info");
            Log.d(TAG, "onDisabled");
            System.out.println("Here in  - onClick3");
           finish();
           break;
        }
     }


}//end class



解决方案

I've experienced this while using LogCat within Eclipse. This happens when the device drops off or loses focus or when you're debugging using 2 or more different devices/emulators.

Try the following:

  1. Go to the DDMS perspective and double-click the application that you're debugging or at least the device. You should see the LogCat tab flood with the new messages.
  2. Remove all devices except the one you're working with at the moment.
  3. Try just using the Log.* functions again.
  4. Set the LogCat filter to Debug or Verbose.

这篇关于为什么我不能看到我的logcat中print语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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