Sex, Lies and Renamed Activities:

…when you get an ActivityNotFoundException and you are certain that you updated your AndroidManifest.xml file I think the hardest aspect of learning a new framework is running into these stupid little issues that leave you stumped for 4 hours, all because I lack the tribal knowledge to instinctively know whats up. So let me tell [...]

…when you get an ActivityNotFoundException and you are certain that you updated your AndroidManifest.xml file

I think the hardest aspect of learning a new framework is running into these stupid little issues that leave you stumped for 4 hours, all because I lack the tribal knowledge to instinctively know whats up.

So let me tell you my story with Android yesterday. I was getting cute with my activity structures and decided to rename them to adhere to a common naming pattern. I should have known better than to rename Activity classes, especially when they are referenced in XML. But you know what, all of you little nerd-bitches have such big hard-ons for Eclipse, that I thought its refactoring tool would be up to the task.

I had an activity named “Login” and used Eclipse to changeits name to “LoginActivity”.I thought all was well after the change, and proceeded to debug.. (you see that is called foreshadowing because we all know what happens next…)

ActivityNotFoundException: cannot find activity ‘LoginActivity’ ….make sure its referenced in the AndroidManifest.xml

Ok, that’s not bad. I get it. I go to the XML file, and I check it, but wait a minute. The Eclipse IDE had already gone through and already renamed the <activity> node to point to the new LoginActivity name.

<activity android:name=”.activities.LoginActivity” android:label=”@string/app_name” />

Hmm. So I re-ran the test, just to make sure it wasn’t some race condition on the saving of the XML and the launching of the APK.

ActivityNotFoundException!

Now I start to be bewildered. Google, Bing, Cheggit, all had no answers for me. I have changed the AndroidManifest god damnit! I can open the file in the IDE and its right!

So I think maybe it’s the fact that the APK wasn’t being updated either locally or pushed to the phone. After deleting the APK and forcing a rebuild and deploy:

ActivityNotFoundException!

I think then maybe it has to do with the namespaces and with the “.” not being present in front of the name value. So I try every permutation/combination of “.” with the LoginActivity and every other activity. After each try:

ActivityNotFoundException!

I then decide to remove all values from the AndroidManifest.xml file. All of it. I rebuild it from scratch using the wizard at the front. After a recompile and debug:

ActivityNotFoundException!

*head smacks desk* . Finally as a last resort, I delete everything out of my AndroidManifest.xml file and re-run.

ActivityNotFoundException!

Wait a minute. That doesn’t make sense. There should be no ActivityNotFoundException, at least not for the LoginActivity class since it shouldn’t be launching as there were no activities defined in the manifest file at all. In fact, I would have expected the Android equivalent of a “no start point found” error. But it appeared the app was launching just like it was before.

Something is up, who can I trust? The Eclipse IDE or the Android application? Neither I decided. So I open up Visual Studio, crack open the AndroidManifest.xml file and what do I see…

<activity android:name=”.activities.Login” android:label=”@string/app_name” />

The exact same file as I had began with before I did my rename of the LoginActivity! For some reason, the Eclipse IDE was letting me edit the file , make changes and save the AndroidManifest.xml file, but the file on the file system wasn’t being updated.

Really?! That’s what caused me to lose 3 hours of valuable productivity?!

I don’t want to sound like a hater, but come on, when was the last time Visual Studio did that to you? I mean VS does a lot of naughty things to me, but lying to me about saving a file has not yet been one of them.

About Bobby Gill

I am the creator of Bahndr, founder of New York based app development lab, Blue Label Labs and editor at Idea to Appster. I like crepes and I am fascinated by big data.

  • http://www.facebook.com/profile.php?id=100003406999885 Jemima

    It’s posts like this that make surfing so much plauesre