How to debug app when it's killed

前端 未结 3 786
予麋鹿
予麋鹿 2021-01-12 17:04

My app has a bug on certain activities: when it restarts (when it\'s killed and then opened again with multitasker), it crashes. I assume it has something to do with my sing

相关标签:
3条回答
  • 2021-01-12 17:44

    I would use DDMS (Dalvik Debug Monitor Server (DDMS) to capture the stack trace, etc.. after your kill and restart our app.

    (FYI: It is already installed along with the rest of the Android toolset)

    While it is not going to allow you to debug you app via VS/XS, it can help you pin the area of your app that is the cause. From there I would add logging around the trouble area (i.e. the old-fashion printf style debugging)

    http://developer.android.com/tools/debugging/ddms.html

    To launch from Visual Studio:

    From Xamarin Studio:

    0 讨论(0)
  • 2021-01-12 17:45

    You can add the following code to the onCreate() method of your main activity:

        android.os.Debug.waitForDebugger();
    

    This will pause your app till a debugger is attached to the process.

    Then :

    • Run your app
    • Put your app in background (say, with the home button)
    • Kill the process or use an app like MemoryPump to fill the RAM and have your app killed by Android
    • Switch back to your app with the multitask pan (the app will start and wait for the debugger)
    • Attach your android studio debugger to you app (icon in the Android Studio toolbar somewhere between the 'run app' icon and the 'stop application' icon)
    • Debug your app
    0 讨论(0)
  • 2021-01-12 17:49

    If you use your singleton class to preload some data the instance will be destroyed when you kill your application so you will have to reload the data that your singleton needs.

    You can also add Raygun which will catch all exceptions and send it to server where you will be able to view the exception details.

    You can get it from nuget: Mindscape.Raygun4Net 5.3.0

    0 讨论(0)
提交回复
热议问题