Search code examples
androidreact-nativeexpoandroid-keystore

Issues with android .keystore after expo eject


I built an app with expo managed workflow, created account with expo and let expo handle all the keystore information i.e. was using expo created keystore credentials and uploaded to play store but my app got rejected due to some reason. I solved the issue but I ejected expo (managed -> bare workflow) and managed to resolve all the errors thereafter. I searched for uploading react native app and followed the steps :

  1. Installed the required jdk version and moved to path where jdk is located

  2. Created new keystore sudo keytool -genkey -v -keystore XXX.keystore -alias XXX-upload -keyalg RSA -keysize 2048 -validity 10000

  3. Entered the required information with the same password for keystore as generated from expo

  4. Placed the keystore file in android>app folder

  5. Made changes in build.gradle under android>app and gradle.properties as recommended for release

         release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    
    

also signingConfig signingConfigs.release

gradle.properties added :

MYAPP_UPLOAD_STORE_FILE=XXX.keystore
MYAPP_UPLOAD_KEY_ALIAS=XXX-upload
MYAPP_UPLOAD_STORE_PASSWORD=XXX
MYAPP_UPLOAD_KEY_PASSWORD=XXX
  1. After all these steps I deleted the bundle from android>app>src>main>assets>index.android.bundle and moved to the android folder of my project with cd android and run ./gradlew clean followed by ./gradlew assembleRelease but got the error :

Task :app:signReleaseBundle FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:signReleaseBundle'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade Failed to read key XXX-upload from store "XXX.keystore": Get Key failed: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.

Searched over stackoverflow for this. Even recreated keystore again, but no help. What can resolve this?

Update: I used same password for both store password and keypassword and I am able to create the app Bundle. But when I submitted the app for release: it says : Your Android App Bundle is signed with the wrong key. Ensure that your App Bundle is signed with the correct signing key and try again. Your App Bundle is expected to be signed with the certificate with fingerprint: SHA1: but the certificate used to sign the App Bundle you uploaded has fingerprint: SHA1:

Is this because I changed my keystore?? How can we fix this ?

Even after restoring keystore back to original keystore by expo managed account, I am able to create .aab but play store not accepting the app . same error for wrong key is generated


Solution

  • You will have to request google play store team for change of keystore related issues. But for the apps uploaded after August 1, 2021 , google has a very beautiful solution. It lets you create an upload key and upload it to play store. Google itself manages your signed app bundles.