1 # apksig 2 3 apksig is a project which aims to simplify APK signing and checking whether APK's signatures should 4 verify on Android. apksig supports 5 [JAR signing](https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Signed_JAR_File) 6 (used by Android since day one) and 7 [APK Signature Scheme v2](https://source.android.com/security/apksigning/v2.html) (supported since 8 Android Nougat, API Level 24). 9 10 The key feature of apksig is that it knows about differences in APK signature verification logic 11 between different versions of the Android platform. apksig can thus check whether a signed APK is 12 expected to verify on all Android platform versions supported by the APK. When signing an APK, 13 apksig will choose the most appropriate cryptographic algorithms based on the Android platform 14 versions supported by the APK being signed. 15 16 The project consists of two subprojects: 17 18 * apksig -- a pure Java library, and 19 * apksigner -- a pure Java command-line tool based on the apksig library. 20 21 22 ## apksig library 23 24 apksig library offers three primitives: 25 26 * `ApkSigner` which signs the provided APK so that it verifies on all Android platform versions 27 supported by the APK. The range of platform versions can be customized if necessary. 28 * `ApkVerifier` which checks whether the provided APK is expected to verify on all Android 29 platform versions supported by the APK. The range of platform versions can be customized if 30 necessary. 31 * `(Default)ApkSignerEngine` which abstracts away signing an APK from parsing and building an APK 32 file. This is useful in optimized APK building pipelines, such as in Android Plugin for Gradle, 33 which need to perform signing while building an APK, instead of after. For simpler use cases 34 where the APK to be signed is available upfront, the `ApkSigner` above is easier to use. 35 36 _NOTE: Some public classes of the library are in packages having the word "internal" in their name. 37 These are not public API of the library. Do not use \*.internal.\* classes directly._ 38 39 40 ## apksigner command-line tool 41 42 apksigner command-line tool offers two operations: 43 44 * sign the provided APK so that it verifies on all Android platforms supported by the APK. Run 45 `apksigner sign` for usage information. 46 * check whether the provided APK's signatures are expected to verify on all Android platforms 47 supported by the APK. Run `apksigner verify` for usage information. 48 49 The tool determines the range of Android platform versions (API Levels) supported by the APK by 50 inspecting the APK's AndroidManifest.xml. This behavior can be overridden by specifying the range 51 of platform versions on the command-line. 52