Up until now I had been signing my apks with the following method:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore {keystore-file} {apk-file} {key
use it this way
./apksigner sign --ks test.jks --ks-key-alias test --ks-pass pass:testtest --key-pass pass:testtest Test_Aligned.apk
I cannot vote/comment yet, but +1 for max's fix:
./apksigner sign --ks test.jks --ks-key-alias test --ks-pass pass:testtest --key-pass pass:testtest Test_Aligned.apk
Prefixing my passwords with "pass:" worked for me
--ks-pass pass:MyPassword
--key-pass pass:MyPassword
Here's what worked for me, I changed this:
--ks-pass "MyPassword"
To this:
--ks-pass pass:"MyPassword"
A weird API to work with... but it worked!
The original answer can be found on the comments of the question, I am moving it here in order to mark the question as answered.
Although I am still not sure 100% of the details, the problem was the password I was using for my keystore contained special characters (* and !). After changing the password to an alphanumeric format, the problem was solved. So it seems like apksigner does not accept the same format for passwords than jarsigner.
Wow, I didn't know you could change passwords in the keystore.
Anyway I had this exact problem and it turns out you don't need to change your password. The trick is to set options
--ks-pass stdin --key-pass stdin
This is supposedly default behavior but in my case it only worked if I specifically included these.
Execute the command, you'll be asked to enter passwords, and it works even with characters such as !.