Note: WTF, Android SDK will be a series about small but significant deviations from the way you’d expect things to work when programming for Android. Well, at least from the way I’d expect them to work. You can read part I HERE

OK. This is going to be a short one, mainly because I have gotten over it.

A bit.

You know how you are supposed to declare Activities and Services (among other things) in AndroidManifest.xml? You probably do, since it’s one of the first things you learn to do as a beginner. Of course, Android Studio will do it for you when you go to File -> New -> Service. When you do it this way, AS will create an entry for your Activity or Service in AndroidManifest.xml and you’re good to go.

But today, you’re in a different mood. You’re feeling frisky! You have a new appreciation for life and all that it has to offer. So you instead decide to go File -> New -> Java Class and extend the Activity class yourself, to see if living on the edge is all it’s cracked up to be.

Five minutes later, you try to launch your newly-created Activity and Android tells you “the app has stopped” or some shit. You go into logcat and you find this

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.cutecomputers.www.optimizemybiz/com.cutecomputers.www.optimizemybiz.activities.BlackIncomeActivity}; have you declared this activity in your AndroidManifest.xml?

(bold mine)

That’s a great question, AS. Have I? No, I have not. Damn.

So you go into AndroidManifest.xml and you create an entry for the Activity and all’s good and fair in the world again.

Two hours later, you want to create a Service that downloads a file from a server. An IntentService would be a great solution to this, right? So, you extend IntentService yourself (remember, you’re extending EVERYTHING yourself today) and do your magic. You launch your app and..

Surprise, mothafucka!

The IntentService does not start. Panicked, you check the code in onHandleIntent() to see what’s going on. Thing is, everything’s looking great. You haven’t commented anything out, you have triple-checked the URL you are passing in your downloadFile() method and you are definitely starting the Service from your Activity.

It has now been two hours and you still haven’t figured it out. Crap. Time to sacrifice a goat. Or a cabbage. Or whatever it is you vegan satanist kids sacrifice nowadays.

But first, you have to go to the toilet. As you drop your pants, it hits you like an 18-wheeler: the Manifest! I have to check the Manifest! Urinating is, like, the hundredth thing on your list right now. You run to your IDE and… it’s not there! You forgot to create an entry for your IntentService in the manifest.

Now, I’m not saying that it’s not your fault. It totally is. But is it too much to ask for the app to crash at the point you are trying to launch the Service? I mean, trying to do the same with an Activity brings your app down and gives you a useful hint in the logcat. Why is it OK for a Service launch to silently fail? What the fuck is this, Javascript?

Or in other words: