I am going to show the simplest and easiest way to finding the reason for app crashing and also the solution. For getting useful videos, Please subscribe to my youtube channel.
You can see in the above video, my app is crashing when I am running my Webview App on Android Studio. you can see no errors appear in my code, but my app is crashing.
For finding the reason first click on the "Logcat" from the android studio, then you will see there is opened a window. There you will select your device, then select your project, then select the "Error".
You can see there is an "Underlined Blue color word", click on that it will show the file name and the code line number where you have an error. There will also show you the reason why your app is crashing. In my case, I have a problem in the "MainActivity.java" file on 125 number line code, My Webview App is crashing for a null object reference.
Because I have taken a variable, but I have not initialized it in OnCreate, also I have not stored my layout design o that variable but I have written function using that variable, So it is showing null object reference.
Now I will give the object reference on that function and then will run my project again. You can see in the video this time my Webview App is running perfectly, not crashing anymore. So I have solved my app crashing problem. You can solve find your app crashing reason and solve this way.
By the way, if you want to know in your app which code is executing, what is happening in your app. you can select Debug from the Logcat. You will be able to see everything there. See you in the next post. Thank you.
No comments:
Post a Comment