2

I always thought that com.google.android.packageinstaller or pm would refuse to install an .APK if its manifest didn't include reverse DNS for the package name.

However, adb shell cmd package list packages returns package:android within the list of standard package names. It's the sole exception, which actually makes it more startling.

Within comparable package managers which utilize such a structure (like flatpak) the rDNS is mandatory in the package manifest. I expected pm to be the same.

Consequently:

  • Is this rule true for applications which the user installs but not the system, perhaps? Or

  • Can a package merely be named anything, yet the convention exists due to the Play Store, or another driving force within the ecosystem?

2
  • Sorry but I don't understand what you mean by this question. The package name of an Android app can be chosen freely just as you want. There is no requirement to match it to anything. It is also not clear why at the end you write something about flatpack, which is totally unrelated to Android as it is only available on Linux distributions (and Android is Linux based but not a Linux distribution).
    – Robert
    Commented Oct 17 at 6:54
  • @Robert, that's indeed what I wasn't aware of and wanted to confirm. I've solely ever seen package names conform to a reverse DNS structure. I mentioned flatpak list merely as a comparator, to demonstrate why I'm surprised, since seeing such an example there would be equally as unusual – though I suppose that in retrospect, it isn't, per your comment. Can you seriously name a package anything? The DNS is mere convention? I've modified the question significantly to make it more comprehensible – I hope it remediates your qualms. Commented Oct 17 at 10:07

1 Answer 1

5

The instructions for setting the application ID in Android Studio make it clear that this name has nothing to do with DNS names. It looks a little like a DNS name, but they have no significant relationship.

It is related to the Java or Kotlin namespace used within the app, but it is not synonymous with that; they often are the same but they need not be.

Every Android app has a unique application ID that looks like a Java or Kotlin package name, such as com.example.myapp. This ID uniquely identifies your app on the device and in the Google Play Store.

Although the application ID looks like a traditional Kotlin or 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_].

It is recommended that you do the following when setting the application ID:

  • Keep the application ID the same as the namespace. The distinction between the two properties can be a bit confusing, but if you keep them the same, you have nothing to worry about.
  • Don't change the application ID after you publish your app. If you change it, Google Play Store treats the subsequent upload as a new app.
  • Explicitly define the application ID. If the application ID is not explicitly defined using the applicationId property, it automatically takes on the same value as the namespace. This means that changing the namespace changes the application ID, which is usually not what you want.

For the reasons for bigger-to-smaller ordering, the reverse of DNS' smaller-to-bigger order, see this Stack Overflow question.

I have never personally set up an applicationId for an Android app, but I have had to use the very similar app identities in iOS. When I did that, I deliberately avoided using the DNS name for the company because that had changed several times in the previous decade. It seemed better to use the long form of the company name, the line of business (which has moved between divisions several times) and an identity for the individual app.

You will find that executive management in large companies don't care about any relationship you may create between DNS names and Android applicationId values. They have people to take care of such things for them, the application developers. If you complain they're creating problems by re-organising the company, they'll hear that as "I can't do my job properly and I'm fool enough to make that obvious."

11
  • 1
    I'd also use this official documentation, but unfortunately it doesn't mention about the (reverse) DNS convention anywhere. Just wanted to add Stack Overflow: Android - Package Name convention for the naming convention following from Java's practice.
    – Andrew T.
    Commented Oct 17 at 10:27
  • @AndrewT.: Thanks, added. Commented Oct 17 at 10:34
  • Summarily, am I correct that as long as I've no interest in publishing an application, I could set its package name to something like myPackage instead of com.MyPackage and pm would be quite happy to install it? Commented Oct 17 at 10:51
  • 2
    @RokeJulianLockhart: I don't know if pm will enforce the "one or more dots" rule. Try it? Commented Oct 17 at 11:31
  • @RokeJulianLockhart your last comment is a bit unclear, whether you're still referring to the reverse DNS requirement (com...) or if it can be a single word. If it's about reverse DNS, then there are many apps in the Play Store that don't follow this convention (example: pdf.tap.scanner).
    – Andrew T.
    Commented Oct 17 at 14:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .