The White Rabbit

It is better to be approximately right than precisely wrong. (Warren Buffet)

Published on Friday, 24 March 2023

Tags: error2 troubleshooting3 bubblewrap1 pwa1

[SOLVED] Problem with Keystore during bubblewrap build for PWA export to Google Play

Keystore and Key are successfully generated by bubblewrap init first, but something goes wrong duirning build. A simple workaround made it work very quickly.


While following these (or these) instructions on how to publish a Progressive Web App to Google Play Store, I bumped into some errors during the bubblewrap build command execution, after generating Keystore and Key using bubblewrap init --manifest=<url-of-manifest.json>.

Essentially, it was about a UnrecoverableKeyException.

cli ERROR Command failed: C:\Users\Giuseppe\.bubblewrap\jdk\jdk-11.0.9.1+1\bin\java.exe -Xmx1024M -Xss1m -jar C:\Users\Giuseppe\.bubblewrap\android_sdk\build-tools\30.0.3\lib\apksigner.jar
[...]
Failed to load signer "signer #1"
[...]
java.io.IOException: keystore password was incorrect
Caused by: java.security.UnrecoverableKeyException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.

Solution

To solve this problem, I did three things:

  • Running the commands in a Windows Shell as Administrator (that's not necessary, but I did it anyways just in case it could be permission-related).
  • Avoiding some special characters in the Keystore/Key password (set during bubblewrap init) , since they were probably causing misunderstanding. Try to build a very long alpha numeric password with upper and lower case letters, but limiting special charaters to those not causing problems for sure (like underscore _).
  • Set the same password for Keystore and Key.