apk (file format)

From HandWiki
Short description: File format for Android software

APK
APK format icon (2014-2019).png
Filename extension.apk, .apks, .aab, .xapk, .apkm, .akp
Internet media typeapplication/vnd.android.package-archive
Type of formatPackage format
Container for
Extended fromJAR

The Android Package with the file extension apk[1] is the file format used by the Android operating system, and a number of other Android-based operating systems for distribution and installation of mobile apps, mobile games and middleware. A file using this format can be built from source code written in either Java or Kotlin.

APK files can be generated and signed from Android App Bundles.[2]

Overview

APK is analogous to other software packages such as APPX in Microsoft Windows, APP for HarmonyOS or a Debian package in Debian-based operating systems. To make an APK file, a program for Android is first compiled using a tool such as Android Studio[3] or Visual Studio and then all of its parts are packaged into one container file. An APK file contains all of a program's code (such as .dex files), resources, assets, certificates, and manifest file. As is the case with many file formats, APK files can have any name needed, but it may be required that the file name ends in the file extension for being recognized as such.[4][5][6]

Most Android implementations allow users to manually install APK files only after they turn on an "Unknown Sources" setting that allows installation from sources other than trusted ones like Google Play. One may do so for many reasons, such as during the development of apps, to install apps not found on the store, or to install an older version of an existing app.[7]

Use on other operating systems

Blackberry Limited supported Android 4.1 Jelly Bean apps and up through Android Runtime to now discontinued Blackberry 10 through the January 2014 10.2.1 firmware update.[8] On June 18, 2014, BlackBerry announced an official relationship with Amazon.com, which resulted in the 10.3 update bundling the Amazon Appstore.

At 2015 Build, Microsoft had also announced an Android runtime environment for Windows 10 Mobile known as "Astoria", which would allow Android apps to run in an emulated environment with minimal changes, and have access to Microsoft platform APIs such as Bing Maps and Xbox Live as nearly drop-in replacements for equivalent Google Mobile Services. Google Mobile Services and certain core APIs would not be available, and apps with "deep integration into background tasks" were said to poorly support the environment.[9][10]

On February 25, 2016, after already having delayed it in November 2015,[11][12] Microsoft announced that "Astoria" would be shelved, arguing that it was redundant to the native Windows Bridge toolkit since iOS is already a primary target for mobile app development. The company also encouraged use of products from Xamarin (which they had acquired the previous day) for multi-platform app development using C# programming language instead.[13][14] Portions of Astoria were used as a basis for the Windows Subsystem for Linux (WSL) platform on the PC version of Windows 10.[15]

On June 2, 2021, HarmonyOS came with APK compatibility on HarmonyOS 2.0 for smartphones and tablets.[16]

At the Windows 11 announcement event in June 2021, Microsoft showcased the new Windows Subsystem for Android (WSA) that will enable support for the Android Open Source Project (AOSP) and will allow users to run Android apps on their Windows desktop. Microsoft confirmed users will be able to sideload Android apps onto Windows and that it would be possible to install APK files downloaded from third-party sources.[17]

Google announced plans in December 2021 to bring Android games to Windows in 2022.[18][19]

Package contents

An APK file is a ZIP archive[20] that usually contains the following files and directories:

  • META-INF directory:
    • MANIFEST.MF: the Manifest file
    • The certificate of the application.
    • CERT.SF: The list of resources and a SHA-1 digest of the corresponding lines in the MANIFEST.MF file; for example:
      Signature-Version: 1.0

Created-By: 1.0 (Android) SHA1-Digest-Manifest: wxqnEAI0UA5nO5QJ8CGMwjkGGWE= ... Name: res/layout/exchange_component_back_bottom.xml SHA1-Digest: eACjMjESj7Zkf0cBFTZ0nqWrt7w= Name: res/drawable-hdpi/icon.png SHA1-Digest: DGEqylP8W0n0iV/ZzBx3MW0WGCA=

  • lib: the directory containing the compiled code that is platform dependent, for example native libraries that can be loaded through JNI; the directory is split into more directories within it:
    • armeabi-v7a: compiled code for all ARMv7 and above based processors only
    • arm64-v8a: compiled code for all ARMv8 arm64 and above based processors only[21]
    • x86: compiled code for x86 processors only
    • x86_64: compiled code for x86-64 processors only
    • mips and armeabi, deprecated since NDK r17[22][23]
  • res: the directory containing resources not compiled into resources.arsc (see below).
  • assets: a directory containing applications assets, which can be retrieved by AssetManager.
  • AndroidManifest.xml: An additional Android manifest file, describing the name, version, access rights, referenced library files for the application. This file may be in Android binary XML that can be converted into human-readable plaintext XML with tools such as AXMLPrinter2, Apktool M, or Androguard.
  • classes.dex: The classes compiled in the dex file format executed by Android Runtime (or by Dalvik virtual machine used in Android 4.4 KitKat).
  • resources.arsc: a file containing precompiled resources, such as binary XML for example.

See also

Further reading

References

  1. "Application Fundamentals" (in en). https://developer.android.com/guide/components/fundamentals. 
  2. Peters, Jay (2021-06-30). "Google is moving away from APKs on the Play Store". https://www.theverge.com/2021/6/30/22557390/google-apk-app-bundles-package-format-play-store. 
  3. "Application Studio". https://developer.android.com/studio/intro. 
  4. "Inside the Android Application Framework" (video). Google Sites. 2008. http://sites.google.com/site/io/inside-the-android-application-framework. 
  5. Hatem Ben Yacoub (20 April 2018). "Tips: How to install apk files on Android Emulator". Open Ha Magazine. http://NextgenApk.com/2008/01/tips-how-to-install-apk-files-on-android-emulator/. 
  6. "The Structure of Android Package (APK) Files". OPhone SDN. OPhone Software Developer Network. 17 November 2010. http://en.ophonesdn.com/article/show/354. 
  7. "Unknown Sources: Everything you need to know!". 27 July 2018. https://www.androidcentral.com/unknown-sources. 
  8. Michael, Kozlowski (29 January 2014). "BlackBerry 10.2.1 Update Allows you to Install APK Files on your Phone". https://goodereader.com/blog/electronic-readers/blackberry-10-2-1-update-allows-you-to-install-apk-files-on-your-phone. 
  9. "How will Android support work in Windows 10 for Phones?". http://www.techradar.com/us/news/software/applications/how-will-android-support-work-in-windows-10-mobile--1293295. 
  10. "Microsoft brings Android, iOS apps to Windows 10". April 29, 2015. https://arstechnica.com/information-technology/2015/04/microsoft-brings-android-ios-apps-to-windows-10/. 
  11. "Microsoft might not bring Android apps to Windows after all". Vox Media. November 16, 2015. https://www.theverge.com/2015/11/16/9742338/microsoft-android-apps-on-windows-on-hold. 
  12. Collins, Katie (November 16, 2015). "Microsoft presses pause on tool for porting Android apps to Windows 10". CBS Interactive. http://www.cnet.com/news/microsoft-presses-pause-on-tool-for-porting-android-apps-to-windows-10/. 
  13. "Microsoft confirms: Android-on-Windows Astoria tech is gone". Conde Nast. February 25, 2016. https://arstechnica.com/information-technology/2016/02/microsoft-confirms-android-on-windows-astoria-tech-is-gone/. 
  14. "An Update on the Developer Opportunity and Windows 10". Microsoft. February 25, 2016. https://blogs.windows.com/buildingapps/2016/02/25/an-update-on-the-developer-opportunity-and-windows-10/. 
  15. Bright, Peter (April 6, 2016). "Why Microsoft needed to make Windows run Linux software". Condé Nast. https://arstechnica.com/information-technology/2016/04/why-microsoft-needed-to-make-windows-run-linux-software/. 
  16. Cheng, Christina (2021-06-12). "Google apps still supported on new HarmonyOS upgraded from EMUI" (in en-US). https://www.rprna.com/updates/harmonyos/google-apps-still-supported-on-new-harmonyos-upgraded-from-emui/. 
  17. Parmar, Mayank (2021-06-27). "Microsoft confirms Android apps will run on all Windows 11 PCs". Windows Latest. https://www.windowslatest.com/2021/06/27/microsoft-confirms-android-apps-will-run-on-all-windows-11-pcs/. 
  18. "Google Play Games - Play Android games on PC" (in en-US). https://play.google.com/googleplaygames. 
  19. Warren, Tom (2021-12-09). "Google is bringing Android games to Windows in 2022" (in en). https://www.theverge.com/2021/12/9/22827037/google-android-games-windows-pc-google-play-games. 
  20. "File format. Apk". 11 October 2019. https://docs.fileformat.com/compression/apk/. 
  21. "ABI Management | Android Developers". https://developer.android.com/ndk/guides/abis.html. 
  22. "Android ABIs | Android NDK" (in en). https://developer.android.com/ndk/guides/abis. "Note: Historically the NDK supported ARMv5 (armeabi), and 32-bit and 64-bit MIPS, but support for these ABIs was removed in NDK r17." 
  23. Dan, Albert (Sep 5, 2018). "Changelog r17" (in en). https://github.com/android/ndk. "Support for ARMv5 (armeabi), MIPS, and MIPS64 has been removed. Attempting to build any of these ABIs will result in an error."