The Curious Case of the Cordova Android Name

Dec 9, 2014 - Updated April 11, 2015 and April 15, 2015.

Extra Note: v4.0.0 of Cordova Android introduces a new config.xml setting: 'android-activityName', which should allow for easy customisation of android:name. Haven't tested it myself yet, but it theoretically should put this problem to bed.

Note: Some recent versions of Cordova use 'MainActivity' instead of 'CordovaApp'. The steps to fix the problem are the same; just replace 'CordovaApp' with 'MainActivity' when relevant.

If you've created a Cordova app for Android recently, you might have noticed something unusual.

Previously if, for example, you had an app called 'NameTest', in the AndroidManifest.xml file there would be android:name="NameTest" in the 'activity' section. As of Android Cordova 3.6.3 and 3.6.4, this will now be android:name="CordovaApp" on all apps.

This probably isn't much to worry about, but Google's documentation recommends being careful if changing this name for previously published apps. And if you want to get the .apk files automatically generated by Cordova to have your app's name instead of a generic 'CordovaApp.apk' name, you'll want to change this.


Why is this happening?

The Cordova team have hardcoded in the 'CordovaApp' name because of potential issues with unusual unicode characters in app names. For English-language apps, this is usually not a problem, but Cordova is an international project and strange characters can cause issues.


How do I fix it?

Thankfully, the fix is not very difficult. Thanks to users at https://issues.apache.org/jira/browse/CB-7827 and http://forum.ionicframework.com/t/android-build-keeps-using-cordovaapp-as-app-name/11702 for the advice.


You need to change 3 things.


THING 1

YOURAPP/platforms/android/AndroidManifest.xml

Open this file and change android:name="CordovaApp" to android:name="YOURAPP".



THING 2

YOURAPP/platforms/android/src/?/?/?/CordovaApp.java

Rename this file to YOURAPP.java



THING 3

YOURAPP/platforms/android/src/?/?/?/YOURAPP.java

Then open the file and change public class CordovaApp extends CordovaActivity to public class YOURAPP extends CordovaActivity



Rebuild your app using cordova build and that's it, problem solved!

Though arguably, there's no real problem to begin with.


Files to change to fix android:name issue

The Ringmaster
ringmaster@cordovacircus.com

comments powered by Disqus