12

As ApkSigner is available in revision 24.0.3 and higher of the Android SDK Build Tools, I have a question: What is the difference between ApkSigner and JarSigner? Why do we need ApkSigner?

Can I sign Apk in the command line for both signers?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Krunal Kapadiya
  • 2,853
  • 3
  • 16
  • 37

1 Answers1

25

jarsigner is designed for signing JAR files and does not know anything about APKs and Android, whereas apksigner is designed for signing APK files and knows what requirements Android places on APK signatures.

For example, jarsigner does not produce APK Signature Scheme v2 signatures introduced in Android 7.0 (Nougat), whereas apksigner does. Another example is that jarsigner does not know that APKs which need to run on API Level 17 or lower must not use SHA-256 digests in their signatures, whereas apksigner knows that.

If you want to sign an APK using one of these tools, use apksigner.

Here's the official documentation about signing from command-line: Sign your app

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alex Klyubin
  • 5,554
  • 2
  • 29
  • 24
  • @KrunalKapadiya Yes. `apksigner sign --ks mykeystorefile --ks-key-alias myaliasname myapkfile.apk` – Yousha Aleayoub Jan 05 '19 at 23:16
  • **Note:** [You cannot use **apksigner** to sign your app bundle.](https://developer.android.com/studio/build/building-cmdline#bundle_build_gradle) – Rumit Patel Aug 30 '22 at 14:29