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

前端 未结 5 1825
有刺的猬
有刺的猬 2020-12-18 02:05

The package naming convention in Android is:

com.organizationName.appName

But if the organizationName or the appName starts with a number o

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-18 02:19

    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.

提交回复
热议问题