44

I want to know that what should be the package name of android app? Means normally we used com.appname OR com.organizationName.appName, But when we are submitting our application in to market then sometimes it shows the errors related to the package name that- Please change Package name. It should not be started with com etc..

I want to know why this happnes? And what should be Right the package name for android application?

If anyone knows the reason or answer of this question then please let me know.

starball
  • 20,030
  • 7
  • 43
  • 238
anddev
  • 3,144
  • 12
  • 39
  • 70

7 Answers7

62

As stated here: Package names are written in all lower case to avoid conflict with the names of classes or interfaces.

Companies use their reversed Internet domain name to begin their package names—for example, com.example.mypackage for a package named mypackage created by a programmer at example.com.

Name collisions that occur within a single company need to be handled by convention within that company, perhaps by including the region or the project name after the company name (for example, com.example.region.mypackage).

Packages in the Java language itself begin with java. or javax.

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. For example:

enter image description here

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
  • 7
    Last package names is not valid in Android Studio, see [Issue 65570](https://code.google.com/p/android/issues/detail?id=65570) – vault Apr 28 '14 at 00:53
11

Android follows the same naming conventions like Java,

Naming Conventions

Package names are written in all lower case to avoid conflict with the names of classes or interfaces.

Companies use their reversed Internet domain name to begin their package names—for example, com.example.mypackage for a package named mypackage created by a programmer at example.com.

Name collisions that occur within a single company need to be handled by convention within that company, perhaps by including the region or the project name after the company name (for example, com.example.region.mypackage).

Packages in the Java language itself begin with java. or javax.

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. For example:

Legalizing Package Names:

       Domain Name                            Package Name Prefix

hyphenated-name.example.org             org.example.hyphenated_name
example.int                             int_.example
123name.example.com                     com.example._123name
user370305
  • 108,599
  • 23
  • 164
  • 151
3

As you stated, package names are usually in the form of 'com.organizationName.appName' - all lowercase and no spaces. It sounds like the package name that you entered when uploading the app was different from the one declared in the AndroidManifest.

spatulamania
  • 6,613
  • 2
  • 30
  • 26
  • Actually before some days I was submitting my application, then market had gave me the message that You should change you package name, "com" is not allowed. Thats why I want to know why this type of message has been came and what is the right package name for android app? Thanks. – anddev Nov 10 '11 at 05:04
  • @Mansi It looks like you tried to use just "com" as your package name. This probably isn't allowed. Package names use to be more fine grained. – spatulamania Nov 10 '11 at 05:06
  • yes I know that only com is not allowed. Actually my package name was "com.organizationName.appName". In that I got that error message. – anddev Nov 10 '11 at 05:23
2

Presently Package name starting with "com.example" is not allowed to upload in the app -store. Otherwise , all other package names starting with "com" are allowed .

aparupa
  • 21
  • 1
2

Package name is the reversed domain name, it is a unique name for each application on Playstore. You can't upload two apps with the same package name. You can check package name of the app from playstore url

https://play.google.com/store/apps/details?id=package_name

so you can easily check on playstore that this package name is in used by some other app or not before uploading it.

Hamza Khan
  • 1,433
  • 13
  • 19
  • What to do if your domain name starts with a number (or only contains numbers)? I get the error "a digit cannot be the first character in a package segment". Am I supposed to lie or make something up??? – Michael Sep 24 '22 at 18:16
1

Visit https://developers.google.com/mobile/add and try to fill "Android package name". In some cases it can write error: "Invalid Android package name".

In https://developer.android.com/studio/build/application-id.html it is written:

And although the application ID looks like a traditional Java package name, the naming rules for the application ID are a bit more restrictive:

  • It must have at least two segments (one or more dots).
  • Each segment must start with a letter.
  • All characters must be alphanumeric or an underscore [a-zA-Z0-9_].

So, "0com.example.app" and "com.1example.app" are errors.

CoolMind
  • 26,736
  • 15
  • 188
  • 224
0

package name with 0 may cause problem for sharedPreference.

(OK) con = createPackageContext("com.example.android.sf1", 0);

(Problem but no error)

con = createPackageContext("com.example.android.sf01", 0);
lennon310
  • 12,503
  • 11
  • 43
  • 61
kimman
  • 371
  • 2
  • 4