Import key store from eclipse to android studio

2019-01-10 19:31发布

问题:

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.

回答1:

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.



回答2:

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.



回答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
    }
}