胖鸭 2014-04-28 23:55
浏览 460
已采纳

不幸的是 MyApp 已经停止了。 我怎样才能解决这个问题?

I am developing an application, and everytime I run it, I get the message:

Unfortunately, MyApp has stopped.

What can I do to solve this?


About this question - obviously inspired by What is a stack trace, and how can I use it to debug my application errors?, there are lots of questions stating that their application has crashed, without any further detail. This question aims to instruct novice Android programmers on how to try and fix their problems themselves, or ask the right questions.

转载于:https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this

  • 写回答

15条回答 默认 最新

  • python小菜 2015-07-01 20:16
    关注

    This answer describes the process of retrieving the stack trace. Already have the stack trace? Read up on stack traces in "What is a stack trace, and how can I use it to debug my application errors?"

    The Problem

    Your application quit because an uncaught RuntimeException was thrown.
    The most common of these is the NullPointerException.

    How to solve it?

    Every time an Android application crashes (or any Java application for that matter), a Stack trace is written to the console (in this case, logcat). This stack trace contains vital information for solving your problem.

    Android Studio

    Finding the stack trace in Android Studio

    In the bottom bar of the window, click on the Logcat button. Alternatively, you can press <kbd>alt</kbd>+<kbd>6</kbd>. Make sure your emulator or device is selected in the Devices panel. Next, try to find the stack trace, which is shown in red. There may be a lot of stuff logged into logcat, so you may need to scroll a bit. An easy way to find the stack trace is to clear the logcat (using the recycle bin on the right), and let the app crash again.

    I have found the stack trace, now what?

    Yay! You're halfway to solving your problem.
    You only need to find out what exactly made your application crash, by analyzing the stack trace.

    Read up on stack traces in "What is a stack trace, and how can I use it to debug my application errors?"

    I still can't solve my problem!

    If you've found your Exception and the line where it occurred, and still cannot figure out how to fix it, don't hesitate to ask a question on StackOverflow.

    Try to be as concise as possible: post the stack trace, and the relevant code (e.g. a few lines up to the line which threw the Exception).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(14条)

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮