How to Use Stack Overflow to Fix Errors During Android App Development in Android Studio?
Last Updated :
14 May, 2021
Stack Overflow, the life savior of developers, feels like Stack Overflow is built for the developers, by the developers, of the developers. According to Wikipedia: “Stack Overflow is a question-and-answer site for professional and enthusiast programmers”. So being a developer or programmer can you imagine your life without Stack Overflow…. ? Most probably the answer is No. This site is the leading Q&A site for developers with more than 18+ million questions, 28+ million answers, and 11+ million users. Whenever developers get stuck in some programming-related problem the first thing they do is Google it. Most of the time the top link that appears in the search result is Stack Overflow. You find the code or the answer to the question you’re looking for.
But a complete newbie in the developer world got confused when he/she opens the Stack Overflow portal. They have no knowledge of how to use this highly popular portal. They only heard about this but not ever used this portal because they don’t know how to use this portal. As a beginner developer (during the development of a college project) do you know how can you use Stack Overflow to Fix Errors whether you are developing some android applications or some web applications. So in this article, we are going to discuss how can you fix errors and what type of errors by using Stack Overflow. Before jumping to the practical implementation let’s have a look at the types of errors a developer faced during application development.
Types of Errors a Developer Faced During Application Development
Basically, there are two major types of errors a developer faced during application development
- Compile-Time Errors
- Runtime Errors
1. Compile-Time Errors
Errors that occur when you violate the rules of writing syntax are known as Compile-Time errors. This compiler error indicates something that must be fixed before the code can be compiled. All these errors are detected by the compiler and thus are known as compile-time errors. The most frequent Compile-Time errors are:
- Missing Parenthesis (})
- Printing the value of a variable without declaring it
- Missing semicolon (terminator)
2. Runtime Errors
Errors that occur during program execution(run-time) after successful compilation are called run-time errors. These types of errors are hard to find as the compiler doesn’t point to the line at which the error occurs.
Let’s fix both types of errors.
Practical Implementation
For the practical implementation, we are going to fix errors that can be occurred during android development and we are using Android Studio as IDE for android development. We are going to demonstrate different scenarios in this implementation.
Case 1: Fixing Compile-Time Errors
In this case, we are going to fix compile-time errors in Android Studio. Suppose during an android app development you have forgotten to add the required image files in the drawable folder or somehow that image file is missing from the drawable folder, and you have no idea of that. And you click on the ‘Run‘ button in Android Studio. Let’s have a look at the below video
So these types of errors are easy to find because already the errors are shown to you in red color, and you can solve them easily. Let’s discuss case 2.
Case 2: Fixing Runtime Errors
Suppose the developer developed a small android application called “Decimal to Binary Number Converter Android App“. This is a very simple app that takes a Decimal number as input from the user and provides the corresponding Binary number to the user. So the developed successfully developed the app and run the app for testing by inputting different decimal numbers. Now you may refer to the video attached below. And have a look at the both emulator and the “Run” tab simultaneously.
You have noted that there is no compile-time errors in this program as we have seen in Case 1. So whenever the user input the value “123” the app successfully run, and you may notice in the “Run” tab there is no error. But whenever the user input a big integer number you may notice that some red color text has been popped up in the Run tab also in the emulator you can see “Our app has stopped” without displaying any reason why it has been stopped. Yes!! here is the point you can see the reason in the “Run” tab. Like here the error is:
java.lang.NumberFormatException: For input string: "1009866544356728881"
So you have to do nothing just copy the error text and put it in Google search as we have done in the above video. And you can see Stack Overflow result is on top. So just refer to the answers and solve your issues accordingly. That’s it.