Skip to content
Coding Fanatic
  • Android Development
  • News and Reviews
  • Road2Pro
  • Tutorials
  • Services
  • About

Bugfix for a Crashing Activity, 51/100 Days of Code

  • October 27, 2019October 27, 2019
  • by Richard Clarke

I ran into an all too familiar bug when adding Activities to an Android Project.

For some reason, the app would crash whenever I tried to start a new Activity. You can find the video on this at the bottom of the page and a link to the source code here.

Whenever I clicked the option in the app for displaying the list of scavenger hunt riddles, it crashed! I checked the onClickListener attached to the TextView option, and the ids used in the layouts. Everything appeared fine. So what was causing the app to crash instead of changing Activities?.

To fix this, I used the debugger to isolate the cause of this bug. The debugger documents errors in a console window and provides useful information for fixing bugs.

After attaching the debugger to my virtual device, I clicked resume in debugger area and used the app as I described earlier. When I clicked the option, the app crashed same as before.

I reviewed the messages in the console window. An error appeared saying it is unable to find the class passed in the intent. The terminal then asks if I updated AndroidManifest.xml with the Activity tags for the new Activity (click below).

Oops. I felt a little embarrassed by this bug. The issue was easy to catch, but the debugger helped me locate the specific issue. I didn’t find errors in my code and the app compiled without issue. The debugger was able to point me in the right direction by logging the distinct cause of the application crash.

For more on this, watch the YouTube video below. For the source code click here

Join the mailing list to see updates like this every week!
Coding Fanatic

Image by Steve Buissinne from Pixabay

Related

Weighted Layouts, 50/100 Days of Code
That’s No List, THIS Is a List! 52/100 Days ofCode
Richard Clarke
Richard is currently a developer using Java and Android Studio to build custom applications for Android. Richard tutored in mathematics at Montgomery College, and worked in Information Technology before entering the Software Development industry as a Quality Engineer.
100daysofcode Android AndroidDev Java

Related articles

Your New Favorite Stopwatch App!…
Two for Two BABY! 7…
…But the App is for…
Play Store Blues – 5…
Top 4 Tips for Android…
No Dice – 3 of…

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • GitHub
  • YouTube
  • X
  • Instagram
  • LinkedIn
My Tweets

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • X
  • GitHub
  • LinkedIn
  • YouTube

Archives

Theme by Colorlib Powered by WordPress