Execution failed for task ':app:packageReleaseBundle'. Can't build app bundle

542

As dumb as this may sound, I spent 24 hours on this and all I had to was enter flutter clean

Share:
542
michaeldebo
Author by

michaeldebo

Updated on December 27, 2022

Comments

  • michaeldebo
    michaeldebo over 1 year

    I get the title and the text below when I try and fail to build an .aab file using flutter build appbundle:

    java.util.concurrent.ExecutionException: java.lang.RuntimeException: jarsignerfailed with exit code 1 : jarsigner: Certificate chain not found for: keystore. keystore must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.

    I had to reset my signing key. The google developer support had me generate a new .jks file with the following command line which I ran from within my project folder:

    keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks
    

    He then instructed me to convert this file into a .pem file using this command:

    keytool -export -rfc -alias upload -file upload_certificate.pem -keystore keystore.jks 
    

    I then emailed him the upload_certificate.pem file. I immediately noticed that the keystore.jks file was red in the sidebar and I get this upon clicking on it:

    "The file 'keystore.jks' is not associated with any file type. Please define the association:"

    The .pem file is also red, but clicking on it shows the text that makes up the key.

    Do I need to reset the signing key again and do something different? Is there a way to fix the issue causing this error?

    • Pierre
      Pierre over 3 years
      It looks like there is a problem in your flutter config. Could you share what your signing config looks?
    • Pierre
      Pierre over 3 years
      Also, googling the error message returned this as first link: stackoverflow.com/questions/23750259/…
    • michaeldebo
      michaeldebo over 3 years
      I saw that link. When i tried the recommend command line, I get this error: keytool error: java.lang.Exception: Keystore file does not exist: formconnect.keystore java.lang.Exception: Keystore file does not exist: formconnect.keystore
    • michaeldebo
      michaeldebo over 3 years
      Do you mean what's in my key.properties file?
    • michaeldebo
      michaeldebo over 3 years
      Here's what's in my key.properties file: storePassword=Test*** keyPassword=Test*** keyAlias=keystore storeFile=/Users/****/Desktop/***/matto_flutter/keystore.jks
    • michaeldebo
      michaeldebo over 3 years
      When I try this command jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore C:\Users***\Desktop***\matto_flutter.keystore matto_flutter.apk keystore I get this response: The operation couldn’t be completed. Unable to locate a Java Runtime that supports jarsigner.
    • Pierre
      Pierre over 3 years
      When you run the command, you have to replace formconnect.keystore with the path to YOUR keystore file, i.e. keystore.jks. That will give list you the aliases of the keys in your keystore.
  • michaeldebo
    michaeldebo over 3 years
    When I replace keyAlias to equaling upload, the error changes to: Execution failed for task ':app:validateSigningRelease'. > Keystore file '/Users/****/Desktop/****/matto_flutter/android/app/upload.j‌​ks' not found for signing config 'release'.
  • michaeldebo
    michaeldebo over 3 years
    Thanks for the help. When I replace the keyAlias with upload, which is the keyAlias, if I change the storeFile to end in /alias.jks I get this error instead: Execution failed for task ':app:validateSigningRelease'. > Keystore file '/Users/****/Desktop/****/matto_flutter/android/app/upload.j‌​ks' not found for signing config 'release'. If I leave the keystore file ending in keystore.jks I get the same error as before.
  • Pierre
    Pierre over 3 years
    Does the file '/Users/****/Desktop/****/matto_flutter/android/app/upload.j‌​ks' actually exist? It looks like you're just pointing to a keystore file that doesn't exist.
  • Pierre
    Pierre over 3 years
    The commands you shared show that the upload keystore you created was named 'keystore.jks' so that's the one you need to reference.
  • michaeldebo
    michaeldebo over 3 years
    When I use the correct Alias and path ending in keystore, I continue to get the error that is the title of this post.
  • Pierre
    Pierre over 3 years
    What do you mean by "the correct alias"? Do you mean "upload"? Did you use the command from stackoverflow.com/questions/23750259/… to check what were the available aliases in the keystore file you're using?