七度&光 2014-04-28 23:55 采纳率: 22.2%
浏览 389
已采纳

不幸的是 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

  • 写回答

16条回答 默认 最新

  • 衫裤跑路 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).

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

报告相同问题?

悬赏问题

  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型