CordovaError: Project name must not begin with a number

Viewed 1196

I'm building an app which name starts with a number "100 Times". But when I try to add the Android platform:

ionic cordova platform add android

I get the following error:

CordovaError: Error validating project name. Project name must not begin with a number

My config.xml is like:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp.times100" ...>
    <name>100 Times</name>
    ...
</widget>

As far as I know it is not a Google Play restriction, cause there are a lot of apps with names that starts with numbers.

How can I use an application name that starts with a number with Cordova?

2 Answers

I was able to use numbers at beginning of my app name following the steps below:

  1. Create the android studio project running "cordova prepare android"
  2. Open the Android Studio Project and edit "res/values/strings.xml"
  3. Replace the "app_name" node content with the name you want.
  4. Build the APK using Android Studio.

That's a cordova bug. There is an issue for that:

https://github.com/apache/cordova-android/issues/584

There's also a pull request to fix it in version 9.x of cordova-android:

https://github.com/apache/cordova-android/pull/859

For now the only way is to use some (hackish) workaround to fix that.

I generate the apk in a CI environment using docker containers, so executing commands manually in Android Studio was out of question in my case, so I forked the cordova-android repo, commented the lines that does that unnecessary (and wrong) validation and installed the android plugin in my project from the forked github repo.

Related