Android applications are packed in a file with the .apk extension. These files are just compressed ZIP files, so their content can be easily explored. An APK file usually contains the following:
- assets/: This is a folder that contains the asset files of the application. This is the same assets folder that exists in our project.
- META-INF/: This is a folder that contains our certificates.
- lib/: This is a folder that contains compiled code, in case it is necessary for a processor.
- res/: This is a folder that contains the application resources such as images, strings, and so on.
- AndroidManifest.xml: This is the application manifest file.
- classes.dex: This is a file that contains the application's compiled code.
- resources.arsc: This is a file that contains some precompiled resources such as binary XML files.
Having the APK file allows the application to be distributed and installed on the
Android operating system. Android applications can be distributed as you prefer:
through app markets such as Google Play, Amazon App Store, or Opera Mobile
Store; through your own website; or even via an e-mail to your users. If you choose
either of the two last options, take into account that Android, by default, blocks
installations from locations different from Google Play. You should inform your
users that they need to disable this restriction in their devices to be able to install
your application. They have to check the Unknown sources option by navigating
to Settings | Securityin their Android devices.
Applications have to be signed with a private key when they are built. An application can't be installed in a device or even in the emulator if it is not signed. To build our application, there are two modes: debug and release. Both APK versions contain the same folders and compiled files; the difference is in the key used to sign them. Both modes are explained as follows:
- Debug: When we ran and tested our application in the previous chapters, we were in debug mode, but we didn't have a key nor did we do anything to sign our application. The Android SDK tools automatically create a debug key, an alias, and their passwords to sign the APK. This process occurs when we are running or debugging our application with Android Studio without us realizing it. We can't publish an APK signed with the debug key created by the SDK tools.
- Release: When we want to distribute our application, we have to build a release version. Google Play requires the APK file to be signed with a certificate, for which the developer keeps the private key. In this case, we need our own private key, alias, and password, and need to provide them to the build tools. The certificate identifies the developer of the application and can be a self-signed certificate. It is not necessary for a certificate authority to sign the certificate.
Keep the key store with your certificate in a secure place. To upgrade your application, you have to use the same key in order to upload the new version. If you lose the key store, you won't be able to update your application. You will have to create a new application with a different package name.
Android Studio Essential
Android Studio Essential

0 komentar:
Posting Komentar