Lesson 124. What is Package for an Application

Lesson 124. What is Package for an Application

In this lesson:

– We understand what Package is for the application

Package can be translated as a package. I will use this translation option in the lesson.

The application package we prescribe in Wizard creating the program.

You can then find it in the manifesto.

By default, it becomes a package for Java classes

Somehow not a particularly significant goal …

Could it be used somehow else? It turns out so. Moreover, a package is an extremely important thing when creating a program. the package is ID applications in the system. That is, when you install an application, the system looks at its package and looks for an already installed application with that package. If not found then everything is ok and the application is installed.

But if found, then here comes into play the mechanism of signing the application key, which we reviewed in the last lesson. The system checks if applications are installed and installed signed by the same key, Then most likely it means that both applications are created one author. And the installed application is by updating installed because their packages and keys are the same. The system installs a new application, replacing the old one – that is, updating the old one.

If the system determines that the applications have been signed with different keysThis means that the applications have been created by various authors, The packages were coincidental and the new one is not an upgrade of the old one. In this case, when installing a new one, it would be old replaced, and so lost (Not updated) because the apps are completely different. And the system does not let you install a new application until you manually delete the old one.

Let’s do a couple of tests. I will create two applications Package1 and Package2 with the same package.

I’ll install first. It appeared in the list.

Now without removing the first one, I will install the second one.

The first disappeared. Only the second remains.

The system decided that the second was an upgrade of the first (because the packages and keys were the same), so the first was safely demolished and replaced with the second. Actually, this is what happens with a regular update.

Now I will sign Package2 with a different key than it was originally signed and try to recover through adb.

parameter r here means that the application must be reinstalled if it already exists.

We see a Failure error [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]. The system checked the keys of the installed and installed applications, saw that they were different and decided that it would not be an upgrade, but simply an application from another developer breaks with the same package. And it made good sense not to remove the existing application, but to warn the user that the keys did not match.

If you throw this application on the emulator and put it through the file manager, we will get about the same message.

From the above, you can draw the following conclusion: your key to which you sign the application in no case can be lost or give it to someone.

If you are the key the losses, Then your app will forever lose the ability to be updated. Even if you create a new key with the same alias, password and owner data, it will still be a different key. And the next version of the program signed by him will be considered by the system not as an upgrade, but as an attempt by an application from another developer to replace your application and prevent it from being installed until you uninstall the installed one.

If you are the key to someone enough, Then this person will be able to make updates for your application without your participation. And if that person also has access to your developer account in the market, they will be able to fill in their version of your application there.

also do not forget storage and key passwords. This will be tantamount to losing the key. In general, treat your keys with all seriousness.

And at the end of the lesson a small lynep. The package has another meaning. As you may have noticed on the Devices tab in Eclipse, the package is used as the name of the process in which the application starts. Thus, under each application the system creates the user. This allows you to differentiate access to data. Each program starts and works with its data in a separate process under a separate user. Accordingly, other applications do not have access to this data because they are running under other users.

In the next lesson:

– we understand ViewPager

Discuss in the forum [9 replies]

Leave a Comment