Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the rule of the name of the packages that start with number?

The package naming convention in Android is:

com.organizationName.appName

But if the organizationName or the appName starts with a number or underscore, it becomes a invalid name, since android doesn't accept words that start with number or underscore.

For example:

com.1organizationName.appName is invalid

What is the convention to rename this package?

like image 449
Dr. No Avatar asked Aug 20 '12 16:08

Dr. No


1 Answers

In the official "Naming a Package" java documentation, it has the following statement:

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, or if the package name contains a reserved Java keyword, such as "int". In this event, the suggested convention is to add an underscore.

So in your case, it would be com._1organizationname.appname

EDIT: Just found this in the Android docs:

A full Java-language-style package name for the application. The name should be unique. The name may contain uppercase or lowercase letters ('A' through 'Z'), numbers, and underscores ('_'). However, individual package name parts may only start with letters.

So apparently it's not quite Java-style. Unfortunately, it looks like your best bet in this case would in fact be to spell out the number, e.g. com.oneorganizationname.appname.

like image 154
Kevin Coppock Avatar answered Sep 28 '22 02:09

Kevin Coppock