DEV Community

Hodeem
Hodeem

Posted on • Edited on

Tidbit: com.android.ide.common.signing.KeytoolException: Failed to read key from store "C:\..\.keystore"

When attempting to create the release bundle for a React Native app, I followed the steps in the (guide)[https://reactnative.dev/docs/signed-apk-android] and generated the keystore. However, when I ran this command to create the release AAB:

cd android
./gradlew bundleRelease
Enter fullscreen mode Exit fullscreen mode

I encountered an error message with the following syntax:

* What went wrong:
Execution failed for task ':app:packageRelease'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
   > com.android.ide.common.signing.KeytoolException: Failed to read key <alias> from store "C:\Users\...\<keystore-name>.keystore": Get Key failed: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
Enter fullscreen mode Exit fullscreen mode

Given that there was no instruction from the CLI to create a key password, this might be a bit confusing.
The solution is to use the keystore password in the key password field in your build.gradle file. For example,

MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
MYAPP_UPLOAD_STORE_PASSWORD=<keystore-password>
MYAPP_UPLOAD_KEY_PASSWORD=<keystore-password>
Enter fullscreen mode Exit fullscreen mode

The reason why this works is that different store and key passwords are not supported for PKCS12 keystores.

If you liked this article, then please support me

Top comments (0)