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
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.
Now I need to enter key store password and key password every time I generate a signed bundle even with a checked "Remember passwords".
It seems to appear with my new configuration of Android Studio 4.2 and Gradle 4.2.0
With the remembered passwords, I now got as the result of generating bundle "Password verification failed"
With re-entering the passwords, the generation goes fine.
What went wrong ?
Update : new version 4.2.1 of Android Studio. Still I can't build two releases in a row :
21:29 Executing tasks: [:app:bundleRelease] in project D:\Android Studio Projects\Acme
21:30 Gradle build finished in 52 s 8 ms
21:30 Generate Signed Bundle
App bundle(s) generated successfully for module 'Acme.app' with 1 build variant:
Build variant 'release': locate or analyze the app bundle.
21:30 Executing tasks: [:app:bundleRelease] in project D:\Android Studio Projects\Acme
21:31 Gradle build failed in 34 s 262 ms
21:31 Generate Signed Bundle: Errors while building Bundle file. You can find the errors in the 'Messages' view.
Execution failed for task ':app:signReleaseBundle'.
A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
Failed to read key acme_alias_name from store "D:\Android Studio Projects\acme\app\my-release-key.keystore": Keystore was tampered with, or password was incorrect
It's a bug introduced in the last studio version. Worked fine for years, with this version after generating a signed APK changing projects or modules results in this error on the next APK generation. They're corrupting the passwords, it's nothing to do with the file name.
You have to change your keystore file name without any special characters and numbers because I also faced same problem, in my case my keystore file name with underscore, I removed the underscore and tried, apk was build successfully. Try this and let us know.
From my point of view, this issue is closed with Android Studio Artic Fox 2020.3.1 Patch 2 version
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.
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.
I'm running Android Studio 0.3.2 and I'm able to correctly generate a signed APK for my application through the Generate Signed APK wizard. Now I wanted to try out the option to additionally run Proguard through that wizard, checking the box 'Run Proguard' and specifying the default proguard-android-optimize.txt config file, as well as a local proguard-project.txt file in the config file paths box below the checkbox. I also made sure the build variant is a Release variant. However after clicking the Finish button an APK is created without errors but apparently it is exactly the same APK as the one obtained with 'Run Proguard' unchecked. Proguard is not called at all. What am I missing here?
Cheers,
Tom.