不幸的是MyApp的已停止。我该如何解决这个问题? [英] Unfortunately MyApp has stopped. How can I solve this?

查看:875
本文介绍了不幸的是MyApp的已停止。我该如何解决这个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个应用程序,每次我运行它,我得到的消息:

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

不幸的是,MyApp的已经停止。

Unfortunately, MyApp has stopped.

我能做些什么来解决这个?

What can I do to solve this?

关于这个问题 - 通过<一个明显的启发href="http://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors">What是一个堆栈跟踪,以及如何使用它来调试应用程序错误?的,有很多的问题,指出他们的应用程序已经崩溃,没有任何进一步的细节。这个问题的目的是指导如何试图解决自己的问题,或者提出正确的问题,新手的Andr​​oid程序员。

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.

推荐答案

这个答案描述检索的堆栈跟踪的过程。已经有堆栈跟踪?阅读上的堆栈跟踪在<一href="http://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors">What是一个堆栈跟踪,以及如何使用它来调试应用程序错误?

您的应用程序退出,因为一个未被捕获的RuntimeException 被抛出。
最常见的是 NullPointerException异常

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

每一个Android应用程序崩溃(或与此有关的任何Java应用程序),一个堆栈跟踪被写入到控制台(在这种情况下,logcat中)的时间。该堆栈跟踪包含解决你的问题的重要信息。

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.

在窗口底部栏,点击安卓按钮。或者,您可以preSS <大骨节病> ALT + <大骨节病> 6 。请确保您的模拟器或设备中的设备面板被选中。其次,尽量找堆栈跟踪,其中显示为红色。可能有很多东西登录到logcat的,所以你可能需要滚动了一下。一个简单的方法来找到堆栈跟踪是再次明确logcat的(使用右侧回收站),并让应用程序崩溃。

In the bottom bar of the window, click on the Android button. Alternatively, you can press alt+6. 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.

在右上角,点击 DDMS 按钮。如果它不存在,则可能需要先使用打开透视按钮,添加到左侧的的Java 按钮。你会发现在底部的logcat的窗格中。首先,确保你的设备在左上设备小组选出。其次,尽量找堆栈跟踪,其中显示为红色。此外,可能有很多东西登录到logcat的,所以你可能需要滚动了一下。一个简单的方法在这里找到的堆栈跟踪是清除的logcat(使用清除日志在右侧顶部的按钮),并让应用程序崩溃了。你也应该点击您的应用程序的包名,如果它不被选中。这将筛选出的,只有你的应用程序所做的日志信息。

In the top right corner, click the DDMS button. If it is not there, you might need to add it first using the Open Perspective button to the left of the Java button. You will find the logcat pane at the bottom. First, make sure your device is selected in the topleft devices panel. Next, try to find the stack trace, which is shown in red. Again, 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 here is to clear the logcat (using the clear log button on the top right), and let the app crash again. You should also click on the package name of your app, if it is not already selected. This will filter out only the log message made by your app.

耶!你中途解决您的问题。
你只需要找出究竟是什么使你的应用程序崩溃,通过分析堆栈跟踪。

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.

阅读上的堆栈跟踪在<一href="http://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors">What是一个堆栈跟踪,以及如何使用它来调试应用程序错误?

如果你发现你的异常和在何地发生,但仍无法弄清楚如何解决它,不要犹豫,问一个关于计算器的问题行。

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.

尽量保持尽可能简明:张贴堆栈跟踪和相关的code(如几行至该扔了异常的行)。

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).

这篇关于不幸的是MyApp的已停止。我该如何解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆