23

I made research on the topic, but couldn't find a solution:

I created a signed apk from an eclipse project, and i also have the eclipse key store. But i couldn"t find out how to import this key store at signing in Android Studio. These are the following things i already tried:

-adding the key store path as it was created originally by eclipse in Android Studio

-adding the path in Android Studio after adding the .jks extension to the original file

In both cases the error is:

Execution failed for task ':application:packageRelease'.

Failed to read key from keystore

So what is the correct way of adding an eclipse keystore to Android Studio?

Any suggestions appreciated, because i have no idea what goes wrong.

AndroidCuriosity
  • 293
  • 1
  • 3
  • 6

3 Answers3

70

I believe this message means that your key alias does not exist. In Android Studio, you can use Build > Generate Signed APK..., enter your key store password, and then browse for a list of key alias in the keystore.

tachyonflux
  • 19,843
  • 7
  • 46
  • 66
  • 4
    Thank you so much! Exactly that was the issue. For others having the same problem: **"Alias"** in Eclipse has to be the same as **"Key store password"** in Android Studio. – AndroidCuriosity Jan 24 '15 at 07:55
  • Very helpful answer for those using the command line! I was struggling while signing to eventually find out that the alias they gave to me didn't exist... Thanks again for the tip :) – Stephen Vinouze Mar 10 '15 at 16:35
  • Correct your answer. Thanks. :-) – allsoft Mar 29 '15 at 12:33
  • FWIW, the issue has nothing to with .jks extension of studio generated keystore – RmK Apr 29 '15 at 07:41
  • 1
    In the 'generate signed apk' window, there is an empty box to the right of the 'key alias' text box you can click to see what you had for a key alias. Since it's empty, at least it was for me, it's not obvious that it does anything. – Androidcoder Jun 24 '15 at 02:08
  • Thanks, Really helped me. – Vasanth Mar 01 '16 at 08:56
  • Thanks really helped me . I was using my jks file after an year. – HourGlass Jul 06 '17 at 05:34
9

I had the same problem and was really frustrated with it. I have solved it and can help you with it.

1) Ensure that your key is uncorrupted and untampered. This is the reason behind most of the problems.

2) Select the path of the key in "Generate Signed APK" dialog box. This path can be anything, it doesn't actually matter.

3) Now just put your keystore password. This needs to be correct, otherwise you will get messages like "Keystore is corrupted", but it isn't.

4) After entering the password, select the Key Alias. If you enter wrong password, this field will be blank.

5) Put the Key Password same as Keystore password. This worked perfectly for me.

Hope it helps all of you. Thanks.

Aritra Roy
  • 15,002
  • 9
  • 70
  • 104
  • 6
    **5) Put the Key Password same as Keystore password. This worked perfectly for me.** it works when error is **Cannot recover key** – Abduhafiz Jan 22 '16 at 12:08
3

This is specified in your Gradle build file, copy the keystore file into your Android Studio project structure, I chose to create a new directory under app called keystores: /app/keystores/release.keystore

signingConfigs {
    debug {
        storeFile file('keystores/debug.keystore')
    }
    release {
        storeFile file('keystores/release.keystore')
        keyAlias ...
        storePassword ...
        keyPassword ...
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
        debuggable true
    }
    release {
        signingConfig signingConfigs.release
        debuggable false
    }
}
darnmason
  • 2,664
  • 1
  • 16
  • 20