Unexpected parameter(s) after input apk (--ks-key-alias): What causes it and how to avoid it
How to Fix Unexpected Parameter(s) After Input APK (--ks-key-alias) Error in Android Studio
If you are an Android app developer, you might have encountered the following error message when trying to sign your APK file using the apksigner tool:
Unexpected parameter(s) after input APK (--ks-key-alias)
This error can be frustrating and prevent you from publishing your app to Google Play or other app stores. In this article, we will explain what APK signing is, why it is important, what causes this error, and how to fix it using three different methods.
unexpected parameter(s) after input apk (--ks-key-alias)
Introduction
What is APK signing and why is it important?
APK signing is the process of digitally signing your APK file with a certificate that proves that you are the author of the app and that the app has not been tampered with by anyone else. Signing your APK file is required by Android before installing or updating your app on a device. It also helps users to verify the authenticity and integrity of your app.
To sign your APK file, you need a private key and a public certificate that are stored in a keystore file. You can use either Android Studio or the apksigner tool from the SDK tools to sign your APK file. The apksigner tool lets you sign APKs and confirm that they will be verified successfully on all versions of the Android platform supported by your app.
What is the unexpected parameter(s) error and what causes it?
The unexpected parameter(s) error occurs when you use the apksigner tool with an incorrect or incomplete syntax. The syntax for signing an APK using the apksigner tool is as follows:
apksigner sign --ks <keystore-file> --ks-key-alias <keystore-alias> <apk-file>
If you omit or mistype any of these options, or add any extra options after the input APK file, you will get this error. For example, if you use --out instead of --ks-key-alias, or if you forget to specify the keystore alias, you will get this error.
How to fix the error
Method 1: Use the correct syntax for apksigner command
Example of correct syntax
The simplest way to fix this error is to use the correct syntax for the apksigner command. Make sure that you specify all the required options in the right order and format. For example, if your keystore file is named mykeystore.jks, your keystore alias is myalias, and your APK file is named myapp.apk, then you should use this command:
apksigner sign --ks mykeystore.jks --ks-key-alias myalias myapp.apk
Explanation of the syntax options
The following table explains what each option in the syntax means:
Option
Description
--ks <keystore-file>
The location and name of your keystore file that contains your private key and certificate.
--ks-key-alias <keystore-alias >> The article is not finished yet. >> >
The alias that identifies your key pair in the keystore file. You can have multiple key pairs in one keystore file, each with a different alias.
<apk-file>
The location and name of your APK file that you want to sign.
You can also use other optional options to customize your signing process, such as --ks-pass to specify the keystore password, --key-pass to specify the key password, --v1-signing-enabled and --v2-signing-enabled to enable or disable APK Signature Scheme v1 or v2, and --out to specify the output APK file name. For more details on these options, you can refer to the .
Method 2: Use a compatible keystore file and password
How to check the keystore file information
Another possible cause of this error is that your keystore file or password is incompatible with the apksigner tool. For example, if your keystore file is in PKCS12 format, you need to convert it to JKS format before using it with apksigner. You can use the keytool command from the JDK to do this conversion. For example, if your PKCS12 keystore file is named mykeystore.p12, you can use this command to convert it to JKS format and name it mykeystore.jks:
How to fix unexpected parameter(s) after input apk (--ks-key-alias) error
Unexpected parameter(s) after input apk (--ks-key-alias) apksigner not accepting password
Apksigner unexpected parameter(s) after input apk (--out)
Unexpected parameter(s) after input apk (--ks-key-alias) android studio
Apksigner.bat sign --ks unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) jarsigner
Apksigner sign --ks-key-alias unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) gradle
Apksigner sign --out unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) command line
Apksigner sign --v1-signing-enabled false unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) build tools 32.0.0
Apksigner sign --v2-signing-enabled false unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) keytool
Apksigner sign --min-sdk-version unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) zipalign
Apksigner sign --max-sdk-version unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) keystore file
Apksigner sign --next-signer unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) certificate chain length
Apksigner sign --debuggable-apk-permitted true unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) signature algorithm name
Apksigner sign --debuggable-apk-permitted false unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) certificate fingerprints
Apksigner sign --help unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) stack overflow
Apksigner sign --version unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) github
Apksigner sign --verbose unexpected parameter(s) after input apk
Unexpected parameter(s) after input apk (--ks-key-alias) android documentation
keytool -importkeystore -srckeystore mykeystore.p12 -srcstoretype pkcs12 -destkeystore mykeystore.jks -deststoretype jks
You will be prompted to enter the source and destination passwords for the keystore files. Make sure that you remember these passwords as you will need them later for signing your APK file.
You can also use the keytool command to check the information of your keystore file, such as the alias, the certificate, and the validity period. For example, if your JKS keystore file is named mykeystore.jks, you can use this command to list its contents:
keytool -list -v -keystore mykeystore.jks
You will be prompted to enter the keystore password. You will then see the details of your key pair and certificate, such as:
Alias name: myalias Creation date: Jan 1, 2020 Entry type: PrivateKeyEntry Certificate chain length: 1 Certificate[1]: Owner: CN=My Name, OU=My Organization, O=My Company, L=My City, ST=My State, C=My Country Issuer: CN=My Name, OU=My Organization, O=My Company, L=My City, ST=My State, C=My Country Serial number: 1234567890abcdef Valid from: Wed Jan 01 00:00:00 UTC 2020 until: Fri Jan 01 00:00:00 UTC 2030 Certificate fingerprints: SHA1: AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD SHA256: AA:BB:CC...DD (truncated for brevity) Signature algorithm name: SHA256withRSA Subject Public Key Algorithm: 2048-bit RSA key Version: 3
Make sure that your alias name matches the one you use for signing your APK file. Also make sure that your certificate is valid and has not expired.
How to create a new keystore file if needed
If you don't have a keystore file or if you want to create a new one, you can use the keytool command from the JDK to generate one. For example, if you want to create a JKS keystore file named mykeystore.jks with a key pair and certificate with an alias of myalias, you can use this command:
keytool -genkeypair -alias myalias -keyalg RSA -keysize 2048 -validity 3650 -keystore mykeystore.jks
You will be prompted to enter the keystore password and some information for your certificate, such as your name, organization, country, etc. You will also be prompted to enter the key password, which can be different from the keystore password. Make >> The article is not finished yet. >> sure that you remember these passwords as you will need them later for signing your APK file.
You can also use other options to customize your key pair and certificate generation, such as -dname to specify the distinguished name for your certificate, -sigalg to specify the signature algorithm, and -storetype to specify the keystore type. For more details on these options, you can refer to the .
Method 3: Use the latest version of Android Studio and SDK tools
How to update Android Studio and SDK tools
The last possible cause of this error is that your Android Studio or SDK tools are outdated and do not support the APK Signature Scheme v2 or v3 that you are using. To fix this, you need to update your Android Studio and SDK tools to the latest version available.
To