Search code examples
javaandroidreact-nativeandroid-gradle-pluginapk

react-native android bundle error keystore load: keystore password was incorrect


When running ./gradlew bundleRelease I get :

Execution failed for task ':app:packageReleaseBundle'.
> java.util.concurrent.ExecutionException: java.lang.RuntimeException: jarsignerfailed with exit code 1 :
  jarsigner error: java.lang.RuntimeException: keystore load: keystore password was incorrect

I followed the official doc here: https://facebook.github.io/react-native/docs/signed-apk-android.html

I tried to put the password in :

  • android/gradle.properties in plaintext as the doc suggests
  • macOS Keychain for obvious security reason
  • android/app/build.gradle in plaintext to exclude a variable issue

I was able to assert :

  • the password passed to android/app/build.gradle was the right one by using java.lang.System.console(password) to print it
  • the keystore password was the right one by using keytool -list -keystore app/my_key.keystore
  • when using keychain, the password was also rightfully set and recovered with security find-generic-password -a [username] -s [keychain_password_key_name] -w

I'm out of option here since I don't usually use Java or Gradle.


Solution

  • Given nobody seems to have the answer and after having dug to the end of the web, I found this :

    https://blog.pieeatingninjas.be/2018/12/12/fixing-appcenter-android-build-error-usr-bin-jarsigner-failed-with-return-code-1/

    The error is misleading and the implementation is wrong (/troll as usual in java).

    Trashing the entire build folder and trying again fixed the problem and got gradle's mind straight.