[android] APK signing error : Failed to read key from keystore

I'm developing android app under intellij and gradle. and using following way to generate keystore file:

keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

then used the keystore file in build.gradle:

signingConfigs {
    robert {
        storePassword 'robert'
        storeFile file('/Users/bournewang/Documents/Project/android.keystore')
        keyPassword 'robert'
        keyAlias 'mike'
    }
}

when finally trying to generate signed apk file: ./gradlew assembleRelease

it gives the error:

Execution failed for task ':Myexample:packageRelease'.

Failed to read key from keystore

This question is related to android gradle apk

The answer is


The big thing is either the alias or the other password is wrong. Kindly check your passwords and your issue is solved. Incase you have forgotten password, you can recover it from the androidStuido3.0/System/Log ... Search for the keyword password and their you are saved


Most likely that your key alias does not exist for your keystore file.

This answer should fix your signing issue ;)


In my case, while copying the text from other source it somehow included the space at the end of clipboard entry. That way the key password had a space at the end.


It could be any one of the parameter, not just the file name or alias - for me it was the Key Password.


For someone not using the signing configs and trying to test out the Cordova Release command by typing all the parameters at command line, you may need to enclose your passwords with single quotes if you have special characters in your password

cordova run android --release -- --keystore=../my-release-key.keystore --storePassword='password' --alias=alias_name --password='password'

In order to find out what's wrong you can use gradle's signingReport command.

On mac:

./gradlew signingReport

On Windows:

gradlew signingReport

Removing double-quotes solve my problem, now its:

DEBUG_STORE_PASSWORD=androiddebug
DEBUG_KEY_ALIAS=androiddebug
DEBUG_KEY_PASSWORD=androiddebug

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to gradle

Gradle - Move a folder from ABC to XYZ A failure occurred while executing com.android.build.gradle.internal.tasks Gradle: Could not determine java version from '11.0.2' Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Failed to resolve: com.android.support:appcompat-v7:28.0 Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)

Examples related to apk

Application Installation Failed in Android Studio Difference between signature versions - V1 (Jar Signature) and V2 (Full APK Signature) while generating a signed APK in Android Studio? Session 'app': Error Installing APK Android Error Building Signed APK: keystore.jks not found for signing config 'externalOverride' Build and Install unsigned apk on device without the development server? The APK file does not exist on disk Android Studio: Application Installation Failed How to retrieve Key Alias and Key Password for signed APK in android studio(migrated from Eclipse) ADB Install Fails With INSTALL_FAILED_TEST_ONLY Upload failed You need to use a different version code for your APK because you already have one with version code 2