简体   繁体   English

在android studio中只调试JAVA代码

[英]debug only JAVA code in android studio

I am new to android. 我是android的新手。 I have developed an app which is working fine. 我开发了一个工作正常的应用程序。 It is a distributed app where different devices can interact with each other with shared data between them. 它是一个分布式应用程序,不同的设备可以通过它们之间的共享数据相互交互。 However what i do is that most of the portion is java code, which i did in NetBeans and then copy paste with minor changes so that it works in the android environment. 但我所做的是,大部分的部分是java代码,我在NetBeans中做了,然后复制粘贴微小的更改,以便它在Android环境中工作。

Now my question is regarding the debugging i don't want the emulator to pop up and process the whole thing, as any input from textbox or any other source, i have provided as a static text to the variables, for debugging sake. 现在我的问题是关于调试我不希望模拟器弹出并处理整个事情,因为来自文本框或任何其他源的任何输入,我已经作为静态文本提供给变量,以便进行调试。 is it possible to just debug the java file and see the result in the log? 是否可以只调试java文件并在日志中查看结果? as i keep testing the code in Netbeans and once it works i copy it to Android, i searched but did not find any answer, but i am sure there will be some way around. 因为我一直在测试Netbeans中的代码,一旦它工作,我将其复制到Android,我搜索但没有找到任何答案,但我相信会有一些方法。

is it possible to just debug the java file and see the result in the log? 是否可以只调试java文件并在日志中查看结果?

actually don't need to debug to get a log because: 实际上不需要调试来获取日志,因为:

log != debug log!= debug


LOGGING 测井

If your app works fine and you want to collect info when app is running (also in the case of errors or failures), configure a complete logging system . 如果您的应用程序正常运行并且您希望在应用程序运行时收集信息 (也是在出现错误或失败的情况下),请配置完整的日志记录系统

Once done, normal app use will generate the info you need just changing to a low logging level like DEBUG , TRACE ... 完成后,正常的应用程序使用将生成您需要的信息,只需更改为低日志级别,如DEBUGTRACE ...

DEBUGGING 调试

If your app has errors and you cannot find/solve it via logs, you need more logs , but you may want to debug it, via device (connecting to the computer) or via emulator 如果您的应用程序有错误并且您无法通过日志找到/解决它,则需要更多日志 ,但您可能需要通过设备(连接到计算机)或通过模拟器进行调试

CONCLUSION: IMHO best option is, once released, implement a logging system always and only debug if log cannot give you enough info to fix the problem. 结论:恕我直言最佳选择,一旦发布,始终实施一个日志系统,只有调试,如果日志不能提供足够的信息来解决问题。


NOTE: as you must know, yes, there is a log level called DEBUG and commands like log.d , that's the level you must implement in the java code for extra info, and set it in your config this info in the moments you have problems, after solving issues, don't forget to return to INFO , ERROR or other high level with less information in order to don't affect performance. 注意:您必须知道, 是的,有一个名为DEBUG的日志级别log.d之类的命令,这是您必须在java代码中实现额外信息的级别,并在您拥有的时刻在您的配置中设置此信息问题,解决问题后,不要忘记返回INFOERROR或其他高级别的信息,以免影响性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM