Welcome! i am sure you have read google play support documents and a couple of stackoverflow posts on how to generate signed private key for google play app signing. I have been through these steps and tried several methods and experimented new ways. Today i find a simple solution and going to share with you how to resolve this Error:
Error: Unable to export or encrypt the private key
java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/NONE/OAEPWithSHA1AndMGF1Padding
at java.base/javax.crypto.Cipher.getInstance(Cipher.java:574)
at com.google.wireless.android.vending.developer.signing.tools.extern.export.ExportEncryptedPrivateKeyTool.encryptPrivateKeyWithCkmRsaAesKeyWrapEncryption(ExportEncryptedPrivateKeyTool.java:284)
at com.google.wireless.android.vending.developer.signing.tools.extern.export.ExportEncryptedPrivateKeyTool.run(ExportEncryptedPrivateKeyTool.java:213)
at com.google.wireless.android.vending.developer.signing.tools.extern.export.ExportEncryptedPrivateKeyTool.main(ExportEncryptedPrivateKeyTool.java:165)
I will not waste your time explaining what methods i tried (believe me i have tried so many methods), let’s go straight to the solution that worked for me. Follow these steps below and leave a comment as a thanks.
Step1:
First thing is to download an openJDK version 21, openJDK21.
Download microsoftOpenJDK21 from microsoft or use a power shell command:
Open power shell, write and execute this command and follow the instructions.
winget install Microsoft.OpenJDK.21
Check Java Path:
when installation completes, open command prompt and check the java path.
the command to check Java Installation Path:
where java
Step 2:
Download a new copy of pubic_encryption_key.pem from your google play app signing dashboard. Also download pepk.jar tool from google play app signing console.
Step 3:
Generate a signed bundle of your app from Android Studio or any other IDE. Assuming you have already created a key store.
Step 4:
Open Command prompt and run the code provided by google play for key encryption.
E:\yourKeystoreAndPublciKeyPath>java -jar pepk.jar --keystore=yourkeystore --alias=yourkeyalias --output=output.zip --include-cert --rsa-aes-encryption --encryption-key-path=encryption_public_key.pem
change the path to your files according to their location.
I am sure it has worked for you, if for some reason you still have any problem, drop a comment and i gladly will help you.
Hope it helps, do comment if you like it and share it with your friends.