DEV Community

Wesley Ruede
Wesley Ruede

Posted on

2

Android errors

Please don't be like me:

// a constructor which initializes items, prices, and descriptions
public ItemAdapter(Context, c, String[] i, String[] p, String[] d ) {
items = i;
prices = p;
descriptions = d;
// initialize LayoutInflater
mInflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

This error took days to get figured out because I couldn't call getSystemServices() on the context. Thankfully there is an Android slack where I was able to get help and continue on with my project. Here is the error free code:

// a constructor which initializes items, prices, and descriptions
public ItemAdapter(Context c, String[] i, String[] p, String[] d ) {
items = i;
prices = p;
descriptions = d;
// initialize LayoutInflater
mInflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

Forget about forgetting semicolons, all it takes is a comma in Java or an apostrophe in xml to throw everything off. It's always the little things, the nuances. This project is still in development so check it out in a day or so to get the complete source code.

What is most funny about this project is that I made the most amatuer mistake. Forgetting to push when the project is still working and then breaking it can be detrimental and a big time waster. Today's big lesson is to always remember to push you code. Always. You don't want to be sad.

Also, if it weren't for Android Studio I would never have caught this error and just kept coding away. A big shout out to Damien Diehl the Android Developer @ Twitch on Slack and Android Studio for keeping me moving. I was seconds from scrapping this project and he came to the rescue like a hero. I really like android development even over web development or data science. This might just be my neeche.

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay