Error validating project name. Project name must not begin with a number.
Why is there a restriction to this? Google Play does not have this restriction.
Is there anything that is affected by this?
https://github.com/apache/cordova-android/blob/a014228f7cb7f4a4583ad6a2b032434f4ce2f4fa/bin/lib/create.js#L225-L228
Yes I' ve seen that. But based on that is there a need to create a class with the projects name?
To tell you the truth the project is being built successfully and works fine even thought it throws the error.
I don't know if that comment should be "can't begin" or "should not begin" ;)
I did a bit of research through the "blame" of that file: The change is 5 years old: https://github.com/apache/cordova-android/commit/141bbfb05134bdd11e262d879bbd253bf4479519 It is based on this issue: https://issues.apache.org/jira/browse/CB-5971 After following links a bit I ended up at https://issues.apache.org/jira/browse/CB-8392 which links to https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html ... which still tells me nothing really.
Maybe we can just remove this check?
This causes issues for us as well, like @deliverymanager says it builds without issues, but if using it as part of a bigger script, it always fails when it adds the Android platform due to this.
I am really struggling with this currently. I need to build some apps whose names begin with a number - however when I run the Cordova build command it seems to try and name my project after whatever is in the name field in my config.xml. If I change this to not be a string beginning with a number, it also renames the app this as well which I need to figure out how to avoid.
I should mention I am using this in a pipeline so manual intervention isn't necessarily ideal. Is there anything I can change in config.xml or anywhere else that will allow me to specify a project name that doesn't begin with a number, but an app name that does? I tried using "<name short=..." to set the name as one beginning with a number - am I on the right track? Am I missing something?
Please help me!
(Asking for individual help in an existing issue about a similar topic is not very nice as it will make it much harder to follow and solve the original issue. Please create a new issue - you can still link here for context.)
Oh man, thanks for letting me know. I am kind of new to all this, so I appreciate you politely correcting my etiquette.
I will create a new issue.
Having the same problem here... I didn't have this issue in my app published last year.
Having the same problem here... I didn't have this issue in my app published last year.
Hey guy,
So I got this sorted out with help from the nice people over in their Slack channel - but to keep it simple, here's what I did to get it going:
I have an APP_BUNDLE_NAME parameter in Jenkins that I use to establish what I want the actual app name to be on device. So in this example say I wanted like "123 App"
In my config.xml template I built, my <name>SOMELETTERS $APP_BUNDLE_NAME</name>
This field influences both the project name and the actual visible app name on the device which is undesirable as is but at least stops the project from complaining about it starting with a number since it should be "SOMELETTERS 123 App" at this point.
In my config.xml I added a hook that looks like this in my Android <hook type="after_prepare" src="scripts/android/fixAndroidName.js" />
All that javascript does, is a find and replace on res/xml/strings.xml which looks for "SOMELETTERS $APP_BUNDLE_NAME" and replaces it with just "$APP_BUNDLE_NAME" which in this case, it would look for "SOMELETTERS 123 App" and replace it with "123 App". I guess that file is where the actual on device name is set.
I don't know much about app development, but example #2 here is what really helped me get it sorted out: https://web.archive.org/web/20180803132745/http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/
Anyway, good luck budday!
I think such a restriction should be removed. The package name must not start with a number, but there should be no such restriction for the project name.
Similar to @rrlevy we didn't have this problem when our app was published. Currently stuck with [email protected] and cordova-android@~8.0.0 as these do not restrict the project name.
Also for anyone using Ionic AppFlow. This requires a separate cordovaOverride script:
#!/bin/bash
set -o errexit #exit with error code if something goes wrong.
if [ -z ${CI_APP_NAME} ]; then
echo "Not in Appflow skipping cordova hack";
else
echo "In Appflow...using [email protected]"
npm uninstall -g @ionic-enterprise/cordova
npm install -g [email protected]
fi
We have an app with a name that starts with a number and did not have any problems for years. Only after upgrading the Cordova version from 8.0.0 to 9.0.0 we are receiving this error.
I have encountered this issue as well. Never used to be a problem.
Ionic:
Ionic CLI : 5.2.5 (C:\Users\dylan\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.6
@ionic/app-scripts : 3.2.4
Cordova:
Cordova CLI : 8.1.2 ([email protected])
Cordova Platforms : android 7.1.4
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 2.5.2, (and 18 other plugins)
Utility:
cordova-res : 0.5.2
native-run : 0.2.7
System:
NodeJS : v12.8.1 (C:\Program Files\nodejs\node.exe)
npm : 6.11.2
OS : Windows 10
There is no such restriction in Google Play.
Just ran my project using cordova-android 8.1.0 and am hitting this error. On 8.0.0 I would get the error after the first time trying to build but then wouldn't after that. With 8.1.0 I keep getting the error and can't build.
I suspect once upon a time project names were used to create a java class, but as far as I can tell it does not do that anymore.
I removed the check altogether and creating a project with the name "123Test" works.
Can run build,
can run run
Can be deployed to a phone or simulator. And as previously mentioned, there are apps on the google play store, such as "8 Ball Pool"
validateProjectName intention is to determine if a given string can be used as an android class and the bad news is, the function itself is exported. It looks like exported purely so the function can be unit tested though, still makes it dangerous to change.
I think moving forward, we can remove the "no starting with a number" condition, and remove the references in comments of it testing for java class name compatibility, and the PR can be included as part of 9.0 release for next breaking change.