<p>I am developing an application and every time I run it I receive the following message: </p>
<blockquote>
<p>Sorry, MyApp has stopped running. </p>
</blockquote>
<p>What should I do to resolve this issue? </p>
<hr/>
Provide more details. This question is intended to guide beginner Android programmers on how to try to solve the problem themselves, or ask the right questions. </em></p>
You can use Google's ADB tool to obtain the
Logcat file
to analyze the problem.Open the
logcat.txt
file and search for your application name. There should be information about the failure reason, line number, class name, etc.This answer describes the process of retrieving a stack trace. Already have a stack trace? Read about stack traces in "What is a stack trace and how do I use it to debug errors in my application?"
questionRuntimeException
How to solve?was thrown.
The most common of these isNullPointerException
.
stack trace
Android Studiois written to the console (logcat in this case). This stack trace contains important information needed to resolve the issue.
Logcat
I found the stack trace, what now?button. Alternatively, you can press
alt 6. Make sure your emulator or device is selected in the Devicespanel. Next, try to find the stack trace shown in red. There may be a lot logged in logcat, so you may want to scroll through it. An easy way to find the stack trace is to clear logcat (using the recycle bin on the right) and let the application crash again.
You just need to find out what exactly caused the application to crash by analyzing the stack trace.
Read about stack traces in "What is a stack trace and how do I use it to debug errors in my application?".
I still can't solve my problem!exception
Try to be concise and clear: post the stack trace andand the line where it occurs, and still can't figure out how to fix it, don't hesitate to ask on StackOverflow.
the relevant code (e.g., a few lines up from the line where the exception
was thrown).