How to change file java.exe to keytool.exe so i can create signed apk for flutter? - flutter

Hi i am currently trying to create a signed apk for a flutter app but I've encounter a problem. Based on official docs https://flutter.dev/docs/deployment/android " Note: The keytool command might not be in your path—it’s part of the Java JDK, which is installed as part of Android Studio. For the concrete path, run flutter doctor -v and locate the path printed after ‘Java binary at:’. Then use that fully qualified path replacing java (at the end) with keytool." and ive check and thats really my situation, now my question is how can i change the location "C:\Program Files\Android\Android Studio\jre\bin\java" to "C:\Program Files\Android\Android Studio\jre\bin\keytool". Thanks for any answer coz i have already search how exactly to do that but failed.

I have found a solution: Simply enter these into Windows command prompt.
italic bold cd C:\Program Files\Java\jdk1.7.0_09\bin
following: How can I find and run the keytool

Yeah Dude I actually solved it my own, I just read the https://flutter.dev/docs/deployment/android again it seams that I didnt change the keytool -genkey -v -keystore c:/Users/USER_NAME/key.jks (<-This is the problem, there is no path on my PC with that name, so just change it) -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key
To solved this issue:
Use this command keytool -genkey -v -keystore c:/Users/USER_NAME/key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key and change the c:/Users/USER_NAME/ with an actual directory.

Related

Keystore file doesn't exist. Unable to get SHA1 key

Unable to get SHA1 key, it is showing error about path, Keystore file doesn't exist.
Tried multiple numbers of solutions,
I am using the following command
keytool -list -v -keystore c:\users\your_user_name\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android
The keystore file does not exists, you have to create it yourself.
Here is the procedure : Generate android release and debug keystores
I had the same problem but I tried below command and interestingly it worked for me under Windows 10.
keytool -list -keystore debug.keystore

How to Export certificate key to PEM format?

My keystore is deleted, and I try to chat with Google playstore developer and I ask that my keystore app be reset, then they sent instructions like this:
Alternatively, you can use the following command line to generate a
new key:
keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks
This key must be a 2048 bit RSA key and have 25-year validity.
Export the certificate for that key to PEM format:
keytool -export -rfc -alias upload -file upload_certificate.pem -keystore keystore.jks
Reply to this email and attach the upload_certificate.pem file.
My question is how to Export the certificate for that key to PEM format?
I try to using keytool.exe in folder C:\Program Files\Android\Android Studio\jre\bin the command prompt keytool.exe can not been write (force close)
keytool is provided in JDK, not JRE. You can install a JDK 1.8 for example and use keytool command from the path C:\Program Files\Java\JDK_1.8\bin\keytool.exe in Windows CMD terminal in Administrator mode(preferably).
The commands you provided are meant to generate a keypair and to export the certificate. So, if you have a proper keytool installed, you can execute your commands successfully and export the certificate.
For exporting certificate, if path not given it will export the ceritificate in bin folder.

build release Ionic does not generate

I'm trying to build the APK to post my plea on Ionic in the Play Store.
But when it comes to the command below I get the error:
PS C:\Projetos\XXX> jarsigner -verbose -sigalg SHA1withRSA
-digestalg SHA1 -keystore android.keystore platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk
android-app-key Picked up _JAVA_OPTIONS: -Xmx512M Enter Passphrase for
keystore: jarsigner:
unable to open jar file:
platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk
And the release is not generated in the APK folder. Can someone help me?
This problem may occur because of the following reasons :
app-release-unsigned.apk does not exist
when executing above command you are not in the release folder, release folder can be found in platforms/android/app/build/outputs/apk/release
keystore does not exist
Verify that you are following these steps
after running ionic cordova build --release android make sure the build is successful and release folder is created under, the path is platforms/android/app/build/outputs/apk/release.
once release folder is created navigate to that folder through terminal
once you reach there generate key store by running following command keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
you can change the key name to anything, in this example the key name is my-release-key, alias name is also up to you, here alias name is alias_name.
the key will be created under the release folder, save this key somewhere else to publish subsequent builds, also save alias name.
Once key is created run jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore app-release-unsigned.apk alias_name here put the same alias name in place of alias_name and keystore name in place of my-release-key.keystore what you choose in step 4, make sure you release apk name is same as app-release-unsigned.apk if it is different change it as well.
in the end run zipalign -v 4 app-release-unsigned.apk myapp.apk, to compress you app, this will create the compressed apk with name myapp.apk it is the same apk that you will use to publish.
Checked whether android.keystore is located in C:\Projetos\XXX directory. Also check app-release-unsigned.apk is present on platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk this path.
I was typing the wrong command. The correct one to generate is
ionic cordova build --release
and then, to generate the key for the first time, I used these commands:
keytool -genkey -v -keystore xxx.keystore -alias xxx-app-key -keyalg RSA -keysize 2048 -validity 10000
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore GestaoDespesas.keystore platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk xxx-app-key
.\zipalign -v 4 platforms\android\app\build\outputs\apk\release\xxx.apk xxx.apk

Is it possible to add crt to cacerts [Java TrustStore] using openssl

Is it possible to add/import .crt [certificate] to cacerts [Java TrustStore] using openssl ?
I do not wish to use keytool & i'm looking for an alternate openssl command for the below:
keytool -import -trustcacerts -alias TorchboxCA -file Torchbox_CA.crt -keystore cacerts
Kindly help me with the command syntax incase it is possible.
As far as I understand the functionality of openssl, no, it will not be possible.
Even in a longer research in OpenSSL manpages and Wiki, I haven't found a hint for Java Key Store (JKS) support.

Because when I run keytool fill all fields and keep asking me back

Because when I run keytool in cmf.exe fill all fields and keep asking me back
keytool -genkey -v -keystore [keystore_name].keystore -alias [alias_name] -keyalg RSA -keysize 2048 -validity 10000
Do not generate the keystore, after asking if everything is correct, and I put yes becomes responsive again. Because? I'm doing wrong?
Not sure what is going wrong for you. And it works for me.
Try giving all the parameters in one go, like this :
keytool -genkey -v -keystore test.jks -alias test
-keyalg RSA -keysize 2048 -validity 10000 -storepass test-keypass test-dname "CN=test.com,OU=Test,O=Test,L=Test,S=Test,C=Test"
This should store the keystore without prompting for confirmation.
I had the same issue, and I realized that it was because of my OS language (I have spanish by default), so when I answered with "si" it worked