Transcript for:
Solving App Crashes in Android Studio

hello everyone in this video I am going to show you how to solve my app crashes even though there is no error in android studio code so its a common mistake thats done here , I wouldn't recommend that it works 100% I don't know maybe the type of error could be different but this also one of the cases in that so this one works for me so I will tell you this one , currently I have a code simple code , I have a button and textview over here and just a simple one , if I press the button the testview will change to "hello" , thats it pretty straightforward and it has a function and here is the reference to it and thats it thats the code , its very simple, the onc (onclick function) given it over here onc in onclick so now I have connected my mobile phone to it and let me just run it I have already ran this program and you can see here installed successfully finished , but in my phone the app has already crashed so first lets get to the basics if your app has crashed just don't go to any other website and type "my app has crashed , how to solve it", you can solve on your own , its very simple to solve it so just go to logcat , run , todo , logcat will be there and here just go to , it will be actually verbose I think so it will show you multiple options , you are just going to select "error" just select error and in this error so you are just search for the link like thing ( blue color underlined text ) So I have only one error actually , thats because its a small program so mainactivity.java 12 so this is mainactivity.java and it shows error in 12 so click it , it will directly take us to the line so whats the error , I don't have any error here but still its showing an error, actually there is an error in it so I will solve it , pretty much simple just going to cut it and paste it inside this function thats it so this is the error , I think many of you would have done this and your app might have crashed , this is the error thats causing it to crash so whenever you declare a textview it must be declared within the function (or globally at the top) , when you have a public onclick call if you have onclicklistener there is no problem , you can directly declare inside the class so whenever you use onclick method you need to declare it inside this (or have it globally declared at the top) , so now let me just run it again so now my app has run successfully so now let me show you again , going to logcat so you see the logcat "error" , there is no error and if you go to verbose also there is no red marks so that shows your app has successfully run 100% , no errors nothing so this is one of the ways , I am not saying this will work or be error for you but this maybe thats what I am saying and thanks for watching and for many such tutorials , I have done on many things in python , unity , android studio so kindly watch that and subscribe and support thank you