javaandroidnumberspackagepackage-name

Numbers in package name Android Studios


I'm trying to create an app ie "1abcxyx". When i create the project in Android studio's.

Ex.

App name:1abcxyz

Company domain:1abcxyz.com

Package name: com.1abcxyz.1abcxyz

It creates the project location but the "next button" is grayed out. A disclaimer comes up and says I cant have # in the package name.

I havent found a way around this.


Solution

  • From the documentation about naming packages in Java:

    In some cases, the internet domain name may not be a valid package name. This can occur if the domain name contains a hyphen or other special character, if the package name begins with a digit or other character that is illegal to use as the beginning of a Java name

    This means you can't use a digit as the first character of a package (or a class, interface or variable name, for that matter).

    To clarify, you can name your app 1abcxyz, it's only the package name that cannot start with a digit (you could use oneabcxyz instead of 1abcxyz for example). Having a package name different from your company's website should not influence communications between your app and your company's servers.