Android: how to debug app's start-up process

你说的曾经没有我的故事 提交于 2019-12-10 03:59:40

问题


I am investigating some issues which happen during my app's startup process, but DDMS won't start the debug mode until the process has started, is there a way I can capture the events earlier?


回答1:


I know that this is a couple of years late, but for any future searches:

Putting WaitForDebugger into your code is one way.

Unlocking developer options (by tapping on the build number in system information on the android device) in Settings allows us to select an application for debugging and then opt to wait for a debugger whenever the program is launched. This allows us do the equivalent of adding and removing WaitForDebugger without modifying and reinstalling the code each time.




回答2:


For Android Studio, here is what worked for me:

  1. Add

android.os.Debug.waitForDebugger();

Where you want to start debugging.

  1. Then add a breakpoint just after it in your code
  2. Compile your app and pass it to your device
  3. Restart your device
  4. Once it's up, attach the debugger:

  5. Start debugging




回答3:


You should implement your own Application class which extends Application and override the methods onCreate and so.. . This class will be your starting point of your app.

also set it as your application in the manifest.



来源:https://stackoverflow.com/questions/16929391/android-how-to-debug-apps-start-up-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!