The JKS keystore uses a proprietary format. It is recommended to migrate
to PKCS12 which is an industry standard format using "keytool
-importkeystore -srckeystore -destkeystore
-deststoretype pkcs12"
I am getting this type of error with android studio 3.4 (32-bit version) at the time of generating the key, but when I am generating the same source code to apk in another laptop with android studio 3.4 (64-bit version). It works fine in 64-bit laptop and android studio.
I encountered the same problem today and it seems that Android wants us to migrate our keys from the JKS proprietary format to the PKCS12 format (as shown in the warning).
To do this, you need to use the keytool, which comes with Android Studio.
1. Locate keytool.exe
The keytool.exe is usually located in the folder C:\Program Files\Android\Android Studio\jre\bin. If you cannot find the keytool there, then you have to search for it.
2. Navigate to the jre folder with the Windows cmd
In Windows, open the cmd and type:
cd C:\Program Files\Android\Android Studio\jre\bin
Of course, if your keytool.exe is stored in another location, you need to enter the correct path after cd
3. Change the keystore format
In the cmd you already navigated to the folder containing the keytool.exe, so now you can enter the following command into the cmd:
keytool -importkeystore -srckeystore your_keystore_destination\your_keystore_file.jks -destkeystore your_keystore_destination\your_keystore_file.jks -deststoretype pkcs12
Don't forget to change
your_keystore_destination\your_keystore_file.jks
with your correct path. In your example it would be
D:\App Collection\App1 All in one Collection\keystorefile.jks
Note:
If you sepcified different passwords for the keystore and for the key, then you need to add -destkeypass your_key_password to the command in step 3!
The following command worked for me on Mac while opening the terminal from the folder where your keyStore file is located:
keytool -importkeystore -srckeystore YOURKEYSTOREFILENAME -destkeystore YOURKEYSTOREFILENAME.p12 -srcstoretype JKS -deststoretype PKCS12
I just ignored this error and used the key generated. I could upload my app without any difficulty.
When you navigate to Build > Generate Signed Bundle / APK and attempt to configure app signing for an app bundle or an APK, entering different passwords for the key and keystore may result in the following error:
Key was created with errors:
Warning: Different store and Key passwords not supported for PKCS12 Key stores
To work around this issue, enter the same password for both the key and keystore.
To work around this issue, enter the same password for both the key and keystore.
Related
I have a Keystore (.jks) which I used to sign the previous release of my App (.APK) for Google Play. That was 1 year ago or so.
Now, when I attempt to build and use my keystore, Android Studio gives me the following incorrect error:
Could not build signed APK. Keystore was tampered with, or password was incorrect.
Android Studio version information:
Android Studio Bumblebee | 2021.1.1 Patch 3
Build #AI-211.7628.21.2111.8309675, built on March 16, 2022
Runtime version: 11.0.11+0-b60-7590822 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.11.0-49-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 12
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin (211-1.6.21-release-334-AS7442.40)
Current Desktop: ubuntu:GNOME
Here is the functionality I'm attempting to run:
Build => Generate Signed Bundle / APK
Displays the following screens...
When I click [Finish] button Android Studio attempts to build & it fails with the error:
Could not build signed APK. Keystore was tampered with, or password was incorrect.
That Is an Incorrect Error
However, that is not correct because I use a password manager to store the password, so I know I have the correct password. I also kept screenshots of the last time I ran this functionality so I could confirm the key alias and it is correct also.
Things I Tried
I tried rebuilding a couple of times & got the error.
I closed & restarted Android Studio & still got the error.
At one point Android Studio crashed with a bug report & I tried again & it failed again.
Why does this error occur?
I discovered some other people reporting what seemed to be an issue with having a password that contained special chars (# !, etc) at this link.
It does seem to be the same failure, but I finally got it to work & I will post the answer.
I started a console window and ran the following against my keystore.
$ keytool -list -keystore 'fakeNmae.jks' -storepass fake-password-same-one-i-used-in-android-studio
I saw the details of my keystore printed out in the console:
Keystore type: JKS Keystore provider: SUN
Your keystore contains 1 entry
fake-alias-name, Dec 15, 2019, PrivateKeyEntry, Certificate
fingerprint (SHA-256): 63:D3:69:69:39:29:5D:5E:14:20:E1:F6:FA:DF:ED
(fake data)
Warning: The JKS keystore uses a proprietary format. It is recommended
to migrate to PKCS12 which is an industry standard format using
"keytool -importkeystore -srckeystore fakeName.jks -destkeystore
fakeName.jks -deststoretype pkcs12".
Since I had to supply my password this confirmed that I was indeed using the correct password.
It also confirms that the keystore was not tampered with (corrupted).
I was a bit confused at this point.
Solution
I started AndroidStudio again & tried it again and it built the signed APK with no problem. I was able to upload it to Google Play.
Very odd. It seems that listing the details somehow fixed the issue in Android Studio. Would love to hear something about this from someone who might know why.
Maybe it has to do with that new warning about the PKCS12 format??
In my case it was the wrong alias, alias is specified during the creation of the keystore, so if the alias is not the same as the one specified during creation you definite get an error.
I'm using the Android Studio 4.1.1 on MacBook, the AS has been updated several times.
I checked How to retrieve Key Alias and Key Password for signed APK in android studio(migrated from Eclipse), but it's not working, there is no AndroidStudio log files under the /Library/Logs directory.
How can I find the password?
I've found the password. Thanks god!
I'ved just updated from android studio 3.0.1 to 3.4, I cant seem to find the option to generate signed apk.
Also , I cant build apk, it has no effect. following is where I click.
https://i.imgur.com/4SGmgGG.png
How to generate signed apk now for android 3.4 ?
Click Generate Signed Bundle/APK in Build menu option.
https://i.stack.imgur.com/rQ6O5.png
The problem was solved with this.
the project was opened with this and caused the problem:
- Open an existing Android Studio project
this actually solved the problem when i opened this way:
import project (Gradle, Eclipse, ADT, etc)
try this
Clean Project
Rebuild project
Invalidate Caches and Restart
And then Build APK
You need to first generate a private key using keytool, For Example:
keytool -genkey -v -keystore my-release-key.jks-keyalg RSA -keysize 2048 -validity 10000 -alias my-alias
The keystore as a file called my-release-key.jks, saving it in the current directory (you can move it wherever you'd like). The keystore contains a single key that is valid for 10,000 days
Sign your app manually from the command line
Sign APK to use zipalign and apksigner as described below.
step 1: Open Android Studio, select View > Tool Windows > Terminal—and navigate directory where unsigned APK.
step 2: unsigned APK using zipalign:
zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk
**step 3:**APK with your private key using apksigner:
apksigner sign --ks my-release-key.jks --out my-app-release.apk my-app-unsigned-aligned.apk
**step 4:**Verify that your APK is signed:
apksigner verify my-app-release.apk
then Configure Gradle to sign your app
I tried to build a signed apk but i wrote an incorrect alias and build failed, now whenever i try to build writing the correct alias and passwords build still fails but the error messagge is:
No key with alias 'old alias' found in keystore
Can someone explain me how do I build with a different alias name?
My keystore and alias passwords are 100% correct.
I know it's a bit old but what worked for me was cleaning the project (in Android Studio, go to option "Build" then "Clean project". It may vary depending on your Android Studio version) and then trying again to generate a signed APK with the right alias.
My ClickOnce installer generates a SmartScreen warning. The executable is signed by a Microsoft Authenticode valid certificate though. The project is generated using Visual Studio 2012 (it's a C# Console Project, containing two DLL, one for JSON and another for PKCS11Interop).
Here is the signing configuration of Visual Studio :
I also added this target after compile in order to digitally sign the executable contained into the installer :
<Target Name="AfterCompile">
<Exec Command=""C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\signtool.exe" sign /f "$(ProjectDir)CertificatCodeSigning.pfx" /p mypassword /v "$(ProjectDir)obj\$(ConfigurationName)\$(TargetFileName)"" />
</Target>
When I take a look at the setup.exe generated, I have this :
But when I take a look at the executable contained into the setup.exe, I have a sha1 digest instead of a sha256 :
When I execute the setup.exe from a Windows 8/8.1, I still get a SmartScreen warning. Can you tell me what I'm doing wrong ?
Thanks in advance,