'javalang.exception:key pair not generated, alias <androiddebugkey> already exists and java.io.filenotfoundexception:debug.keystore

I enter the following

keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

in cmd to generate debug keytool.

However, I received the error

java.io.filenotfoundexception:debug.keystore" instead. Afterwhich I changed the above command to "keytool -genkey -v -keystore C:\Users\me.android\debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

And this time I received another error

javalang.exception:key pair not generated, alias already exists

What goes wrong here? What I am trying to do here is just to generate a new debug keystore.



Solution 1:[1]

Found out that you need to delete the existing debug.keystore before generating a new debug.keystore. When generating a new debug.keystore, you need to list the directory where you want to store the keystore file.

After delete the old debug keystore, enter the below command in android studio terminal:

keytool -genkey -v -keystore debug.keystore C:\Users\abc\.android\debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

Where debug.keystore is the name you want to define your keystore file, C:\Users\abc\.android\debug.keystore is the directory where you want to store the keystore

Solution 2:[2]

Based on a suggestion from others, I actually deleted debug.keystore, hence the file not found exception

Below worked:
- Retrieved debug.keystore back form recycle bin
- Reverted to old keys, instead of new upload keys. The old key was generated using android studio.

Reverted to old key is because play console rejected the upload of new app release as an update to older one.

Solution 3:[3]

when you creating next app (you always created one)there was alwasys upload-keystore.jks .so first you have to delete that. then paste your code in terminal

On Mac/Linux, use the following command:

content_copy

keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload

On Windows, use the following command:

content_copy

keytool -genkey -v -keystore c:\Users\USER_NAME\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload

Solution 4:[4]

I encountered this error and what I had to do was to delete the upload-keystore.JKS file from the original path given when creating it the first time and the project itself. For me, I had to delete it from

  1. My Project in Android studio

    android/app folder

And also, from my computer

/Users/bojack folder

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matt Hampel
Solution 2 Manohar Reddy Poreddy
Solution 3 Rasathurai Karan
Solution 4 dev.bojack