Cordova 4.3 upgrade gives FATAL EXCEPTION: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{my.app.identifier/my.app.identifier.CordovaApp}

Reading Time: 2 minutes

cordovalogoYou know the sequence: After figuring out there’s a new version of Cordova/Phonegap you check in your sources in your GIT repo and make sure all is backed up before upgrading them tools.
Then you’ll start kicking it with $ npm update -g cordovaAnd don’t forget upgrading ios-deploy (with npm install -g ios-deploy) and upgrading your platform project structure to take advantage of the latest candy using cordova platform upgrade .

I did the same for the upgrade from Cordova 4.2 to 4.3 The upgrading commands are all documented very well on the tools release post over here. Compiling my projects went fine so I was happy once more.

But then lightning struck down Cordova lane: Trying to run the Android version of my project on some GenyMotion VM’s made clear that the build wasn’t valid anymore.. I was getting dreaded FATAL EXCEPTION issues and the app closed as fast as it was opened on the device!

omgO..M..G..

Check out this post on how I found out why this was happening and the easy fix that was needed. Maybe it’ll save you the time and blood pressure and you’ll live yet another day to do good in this world.

TL;DR: change android:name in the AndroidManifest.xml for the object definition into “MainActivity” (previously “CordovaApp”).

[ad name=”Large Rectangle”]

Checking out the logcat showed me the cause for the issue that was causing the killing spree of my activity:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{my.app.identifier/my.app.identifier.CordovaApp}

Caused by: java.lang.ClassNotFoundException: Didn’t find class “my.app.identifier.CordovaApp” on path: DexPathList….

CordovaApp is the default name property for the initial Android Activity that will be fired up by the Cordova generated project…

…At least, in Cordova 4.2 generated apps. After burning an hour discovering what change on my side could have caused the issue I started suspecting the tooling upgrade to Cordova 4.3. The only thing I could do is check if there were new settings needed the new Cordova CLI tooling by generating a new test project (using $cordova create test my.app.identifier) and checking if there were differences in the AndroidManifest.xml file.

And sure there was the little undocumented change that caused the fatal exception:

See the difference? The Cordova baked Android project now expects “MainActivity” to be defined as the name. Not having clear upgrade docs on these type of configuration changes can cost you quite some time…

Be sure to check and change your project’s name property in the AndroidManifest.xml file when upgrading to Cordova 4.3 and skip the debugging hours that I’ve spend on this…

Cheers