i'm trying to prepare my app for publishing to play store, bur while i'm creating the app bundle, this error shows up too many times, i was recreate the keystore but it's failed again,
i want to mention that when i setup keystore it's asks me for keystore password just without keypass
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[ ]
> Failed to read key key from store "/Users/ahd/key.jks": Invalid keystore format
I had this issue and it was because of the version of Java I was using. I used the keytool within Android Studio to generate the keystore instead and this fixed the issue for me.
Run flutter doctor -v and look for the "Java binary at:" entry. Then use this path swapping 'java' for 'keytool' to generate your keystore. For example
/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/bin/keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
In my case I also followed the recommendation that popped up at the end of this to migrate to PKCS12 (once again using the keytool in Android Studio).
Related
I'm trying to deploy my Flutter app to Android. According to the Flutter documentation we have to sign our apps. The first step is to create an upload keystore. There are apparently two ways to do this.
The first method uses Android Studio. The instructions say:
In the menu bar, click Build > Generate Signed Bundle/APK.
Here's a screenshot of Build in Bumblebee 2021.1.1:
Where is Generate Signed Bundle/APK?
I clicked Build > Flutter > Build App Bundle. This ran for awhile and finished without error messages.
The second method uses the CLI. You enter this (on a Mac or Linux):
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
That prompted me for a keystore password. What is that and where do I get one?
I'm supposed to see a upload-keystore.jks file in my home directory. Does this mean in my project's home directory or my user home directory? I don't see that file.
Next, I'm told to
Create a file named [project]/android/key.properties that contains a reference to your keystore:
storePassword=<password from previous step>
keyPassword=<password from previous step>
keyAlias=upload
storeFile=<location of the key store file, such as /Users/<user name>/upload-keystore.jks>
What password from what previous step? And where is the key store file located?
I apologize if this is all obvious to Android users. I've always used iPhones. I bought my first Android phone yesterday and this is completely baffling to me.
Thank you #ישו אוהב אותך. The mistake is that when you run
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
it prompts you: Enter keystore password: It should say Create new keystore password or Enter new keystore password.
I made up a unique new password swordfish and entered it. I was prompted for my name and address and then told:
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 /Users/TDK/upload-keystore.jks -destkeystore /Users/TDK/upload-keystore.jks -deststoretype pkcs12".
So apparently there's a second item that needs to be updated in the documentation.
I ran the new command and now I see a file upload-keystore.jks in my user home directory (not in my project home directory).
I'll post a ticket with Flutter the make these two updates.
I've published a few apps but eventually will need to do updates, most of the time it's fine, but soon enough.. I get an error when updating my app saying the fingerprint certificate is wrong. Answers all point to the need to save and reuse the original keystore or you're SOL. Just a few things to explain:
I have no clue what a keystore is.
I have no clue how to save it when making an app.
I have no clue how to restore it in future versions of my app that have used an alternate keystore for some reason or other.
What I'm trying to figure out is, what's the best practice to ensure that whenever I'm messing with my app to future develop it, how do I prevent changing this damn keystore? Is it whenever I update cordova? Update a platform? etc.. I feel like my apps have a ticking time-bomb that eventually stops it from being able to update on the Play Store. I'm using Cordova btw.
Been doing some research for about a day and a half before asking, so any help is appreciated.
Here's what I've gathered...
STEP ONE - CREATE A .KEYSTORE FILE:
Navigate to C:\Program Files\Java\jre7\bin (usually this), open command window and type:
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
STEP TWO - CREATING AN UNSIGNED VERSION OF YOUR APP
Build an unsigned version of the app in a command window that's opened in your project folder:
cordova build android --release
STEP THREE - SIGN THE RELEASE WITH YOUR SAVED KEYSTORE
Running the first command below will show all entries in your keystore, look for Alias name’ in the output, then use that value in the second command. In CMD:
keytool -list -v -keystore /path/to/your.keystore
jarsigner -sigalg SHA1withRSA -digestalg SHA1 -keystore /path/to/your.keystore android-release-unsigned.apk alias_name
STEP FOUR - CHECKING YOUR WORK:
Let's make sure everything was updated correctly before adding your app, otherwise you may run into this mess all over again.
First, unzip the APK and extract the file /META-INF/ALIAS_NA.RSA (this file may also be CERT.RSA or other, but there should only be one .RSA file).
Then issue this command:
keytool -printcert -file ALIAS_NA.RSA
You will get certificate fingerprints like this:
MD5: B3:4F:BE:07:AA:78:24:DC:CA:92:36:FF:AE:8C:17:DB
SHA1: 16:59:E7:E3:0C:AA:7A:0D:F2:0D:05:20:12:A8:85:0B:32:C5:4F:68
Signature algorithm name: SHA1withRSA
Then use the keytool again to print out all the aliases of your signing keystore:
keytool -list -keystore my-signing-key.keystore
You will get a list of aliases and their certificate fingerprint:
android_key, Jan 23, 2010, PrivateKeyEntry,
Certificate fingerprint (MD5): B3:4F:BE:07:AA:78:24:DC:CA:92:36:FF:AE:8C:17:DB
We can now determine the apk has been signed with this keystore, and with the alias 'android_key'.
Keytool is part of Java, so make sure your PATH has Java installation dir in it.
Store this somewhere you'll remember and use information where you'll remember (or safely store this info somewhere, a tattoo comes to mind).
STEP FIVE - ZIPALIGN YOUR APP: Navigate to your Android SDK folder and search for zipalign, use the most recent one. Then:
zipalign -f -v 4 "path/to/unsigned-apk" "path/you/want/signed/apk"
A lot of this info was found from all over stackoverflow, then compiled here for myself and others to reference in the future.
I am trying to post an app created through Apache Cordova using Visual Studio 2015. I have been able to export the .APK successfully but I have not been able to find a keystore in order to sign this .APK so I can post it.
I can not find a keystore anywhere in the Visual Studio project build and whenever I try to run the CMD it says that I have an "Illegal Option: aaaa-key.keystore keytool -genkeypair" and doesn't generate a Keystore.
If there is no Keystore generated by the IDE (that I could find) and my CMD isn't creating one as instructed from MSN then I feel kind of stuck. Please help.
You can generate a new key with this command:
First open cmd and then type:
cd C:\Program Files (x86)\Java\jdk1.7.0_55\jre\bin
Then run:
keytool -genkeypair -v -keystore YourKeyName.keystore ^
-alias YourKeyName -keyalg RSA -keysize 2048 -validity 10000
I am developing an application for Android with Cordova 5.1.1.
I want to create a signing APK to upload to Google Play.
I create a release key by running this command on /Applications/rubystack/apache2/htdocs/apps/myapp
keytool -genkey -v -keystore myapp-release-key.keystore -alias my_app -keyalg RSA -keysize 2048 -validity 1000
Then I create a release-signing.properties file on platforms/android. This is the contents in the file.
storeFile=/Applications/rubystack/apache2/htdocs/apps/myapp/myapp-release-key.keystore
keyAlias=my_app
keyPassword=mypassword
storePassword=mypassword
But, when I tried to compile with command cordova build android --release, I got an error.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':packageRelease'.
> Failed to read key from keystore
Why can it happen and how to solve this?
Thank you
I had the same problem and this is the way i solved it:
Steps
With administrator privileges run: keytool -genkey -v -keystore
c:\my-release-key.keystore -alias appS -keyalg RSA -keysize 2048
-validity 10000
Answer the questions that will come up and attention to the last
question:
"Enter key password for
(RETURN if same as keystore password):",
Give a pass which you will use in the next (last) step
In the build.json file for field "password" give the password that
you gave in the previews step (2)
I'm using Eclipse, and except for the default keystore path specified in windows->preferences->android->build, I didn't specify any other customized keystore path in eclipse.
I have the debug.keystore in two locations. one is in the default path, and the other say c:\customised_path.
however, when i wanted to generate the cert:
keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 20000
it'll generate the debug.keystore in the java\bin folder.
and if i try:
C:\Java\jdk1.6.0_25\bin>keytool -genkey -v -keystore C:\default_path\.android\d
ebug.keystore
keytool error: java.io.IOException: Invalid keystore format
java.io.IOException: Invalid keystore format
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:633)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:3
8)
at java.security.KeyStore.load(KeyStore.java:1185)
at sun.security.tools.KeyTool.doCommands(KeyTool.java:620)
at sun.security.tools.KeyTool.run(KeyTool.java:172)
at sun.security.tools.KeyTool.main(KeyTool.java:166)
it'll gimme the same error to generate the key in the customized path too.
i have debug.keystore in both folders still i'll have this:
C:\Java\jdk1.6.0_25\bin>keytool -list
keytool error: java.lang.Exception: Keystore file does not exist: C:\customiesed_path\.keystore
and
C:\Java\jdk1.6.0_25\bin>keytool -list -keystore C:\the_default_path_specified_in_eclipse.keystore
keytool error: java.lang.Exception: Keystore file does not exist: C:\default_path
Eclipse is using the .keystore in the default folder to sign the apk, and i have the .keystore in the default folder, but it just doesn't allow me to sign it and gives me annoying error when I try to run my application.
Could somebody help here please?
Bingo! problem solved! it seems that the .keystore is somehow changed and after I re-download it, it works again.
I re-downloaded the .keystore that I need to use and run eclipse again. Now everything works normal. So next time someone has problems generating apk file using an existing key, please take into consideration "run" in eclipse not from cmd as well as download a new keystore.
One more thing: signing in debug mode is different from release mode! Eclipse uses "run" to sign in debug mode. Using command line won't work because they're simply for release.