Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native: Android: Cannot generate signed APK

Execution failed for task ':app:packageRelease'.
Failed to read key my-key-alias from store
"/Users/MichaelLeung/GHRepos/MyApp/android/app/my-release-
key.keystore": Keystore was tampered with, or password was incorrect

I'm positive my password is correct; I've gone through the steps that Facebook lists on the React Native docs multiple times.

like image 612
sdfsdf Avatar asked Aug 18 '16 23:08

sdfsdf


2 Answers

So if you were trying to generate a signed APK and used a no ASCII letter, you'd probably get this error.

Execution failed for task ':app:packageRelease'.

com.android.ide.common.signing.KeytoolException: Failed to read key my-key-alias from store "/Users/.../.../.../android/app/my-release-key.keystore": keystore password was incorrect

I couldn't find a way to reset the old password.

Thankfully there is a work around, using the Android Studio.

First I had to remove all the code from gradle.properties and build.gradle, (that I had to add according to the docs..

This solution is from a a comment here: Keystore password was incorrect "I am facing the same issue. Using Build -> Generate Signed APK in android studio works, but putting the config in build.gradle doesn't."

Then use the "signing/keytool UI that's part of Android Studio", which can be found in Build -> Generate Signed Bundle/APK ...

There you can create a new key store password and a key password WHICH HAVE TO BE THE SAME!!!

Note after finishing, Android Studio saves the app-release.apk file in android -> app -> release.

Happy coding :)

like image 184
Fotios Tsakiris Avatar answered Oct 15 '22 10:10

Fotios Tsakiris


I had the same problem. After hard coded the settings in the build.gradle, instead off set it in the gradle.properties, is was working.

  signingConfigs {
    release {
        //if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file("key.keystore")
            storePassword "****"
            keyAlias "myKey"
            keyPassword "****"
       // }
    }
}

After further testing with java.lang.System.console(MYAPP_RELEASE_STORE_PASSWORD) I saw that there was a space after my password.

  signingConfigs {
    release {            
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
        java.lang.System.console(MYAPP_RELEASE_STORE_PASSWORD)

            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}
like image 44
Yoruba Avatar answered Oct 15 '22 11:10

Yoruba