What are the steps to create a keystore for android?
I need to use google maps in my app and I don't know what steps I missed.
Please provide me with the specific detailed steps (I didn't understand it from the guides).
To answer the question in the title, you create a keystore with the Java Keytool utility that comes with any standard JDK distribution and can be located at %JAVA_HOME%\bin. On Windows this would usually be C:\Program Files\Java\jre7\bin.
On Windows, open a command window and switch to that directory. On Linux type OS do the same with a terminal. Then run:
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
Keytool prompts you to provide passwords for the keystore, provide the Distinguished Name fields and then the password for your key. It then generates the keystore as a file called my-release-key.keystore in the directory you're in. The keystore and key are protected by the passwords you entered. The keystore contains a single key, valid for 10000 days. The alias_name is a name that you — will use later, to refer to this keystore when signing your application.
For more information about Keytool, see the documentation at: http://docs.oracle.com/javase/6/docs/technotes/tools/windows/keytool.html
and for more information on signing Android apps go here: http://developer.android.com/tools/publishing/app-signing.html
Signing Your App in Android Studio
To sign your app in release mode in Android Studio, follow these steps:
1- On the menu bar, click Build > Generate Signed APK.
2-On the Generate Signed APK Wizard window, click Create new to create a new keystore.
If you already have a keystore, go to step 4.
3- On the New Key Store window, provide the required information as shown in figure
Your key should be valid for at least 25 years, so you can sign app updates with the same key through the lifespan of your app.
4- On the Generate Signed APK Wizard window, select a keystore, a private key, and enter the passwords for both. Then click Next.
5- On the next window, select a destination for the signed APK and click Finish.
referance
http://developer.android.com/tools/publishing/app-signing.html
I was crazy looking how to generate a .keystore using in the shell a single line command, so I could run it from another application. This is the way:
echo y | keytool -genkeypair -dname "cn=Mark Jones, ou=JavaSoft, o=Sun, c=US" -alias business -keypass kpi135 -keystore /working/android.keystore -storepass ab987c -validity 20000
dname is a unique identifier for the application in the .keystore
cn the full name of the person or organization that generates the .keystore
ou Organizational Unit that creates the project, its a subdivision of the Organization that creates it. Ex. android.google.com
o Organization owner of the whole project. Its a higher scope than ou. Ex.: google.com
c The country short code. Ex: For United States is "US"
alias Identifier of the app as an single entity inside the .keystore (it can have many)
keypass Password for protecting that specific alias.
keystore Path where the .keystore file shall be created (the standard extension is actually .ks)
storepass Password for protecting the whole .keystore content.
validity Amout of days the app will be valid with this .keystore
It worked really well for me, it doesnt ask for anything else in the console, just creates the file. For more information see keytool - Key and Certificate Management Tool.
Create keystore file from command line :
Open Command line:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved
// (if you want to store keystore file at C:/ open command line with RUN AS ADMINISTRATOR)
C:\Windows\system32> keytool -genkey -v -keystore [your keystore file path]{C:/index.keystore} -alias [your_alias_name]{index} -keyalg RSA -keysize 2048 -validity 10000[in days]
Enter > It will prompt you for password > enter password (it will be invisible)
Enter keystore password:
Re-enter new password:
Enter > It will ask your detail.
What is your first and last name?
[Unknown]: {AB} // [Your Name / Name of Signer]
What is the name of your organizational unit?
[Unknown]: {Self} // [Your Unit Name]
What is the name of your organization?
[Unknown]: {Self} // [Your Organization Name]
What is the name of your City or Locality?
[Unknown]: {INDORE} // [Your City Name]
What is the name of your State or Province?
[Unknown]: {MP} //[Your State]
What is the two-letter country code for this unit?
[Unknown]: 91
Enter > Enter Y
Is CN=AB, OU=Self, O=Self, L=INDORE, ST=MP, C=91 correct?
[no]: Y
Enter > Enter password again.
Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days
for: CN=AB, OU=Self, O=Self, L=INDORE, ST=MP, C=91
Enter key password for <index> (RETURN if same as keystore password):
Re-enter new password:
[ Storing C:/index.keystore ]
And your are DONE!!!
Export In Eclipse :
Export your android package to .apk with your created keystore file
Right click on Package you want to export and select export
Select Export Android Application > Next
Next
Select Use Existing Keystore > Browse .keystore file > enter password > Next
Select Alias > enter password > Next
Browse APK Destination > Finish
In Android Studio:
Create keystore [.keystore/.jks] in studio...
Click Build (ALT+B) > Generate Signed APK...
Click Create new..(ALT+C)
Browse Key store path (SHIFT+ENTER) > Select Path > Enter name > OK
Fill the detail about your .jks/keystore file
Next
Your file
Enter Studio Master Password (You can RESET if you don't know) > OK
Select *Destination Folder * > Build Type
release : for publish on app store
debug : for debugging your application
Click Finish
Done !!!
This tutorial:
“sign-your-android-applications-for.html”
Archived here:
https://web.archive.org/web/20181002011446/http://techdroid.kbeanie.com/2010/02/sign-your-android-applications-for.html
was very helpful for me the first time I had to create a keystore. It is simple but the instructions on developer.android.com are a little too brief.
The part I was unsure about was where to save and what name to give the keystore file.
I seems it doesn't matter where you put it just be sure to keep it safe and keep a number of backups.
I just put it in my app directory
Name the file "something.keystore" where something can be whatever you want. I used app_name.keystore, where app_name was the name of my app.
The next part was what to name the alias. Again it doesn't seem to matter so again I just used the app_name again. Keep the passwords the same as you used before. Fill out the rest of the fields and you are done.
Use this command to create debug.keystore
keytool -genkey -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US"
I followed this guide to create the debug keystore.
The command is:
keytool -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999
First thing to know is wether you are in Debug or Release mode. From the developer site "There are two build modes: debug mode and release mode. You use debug mode when you are developing and testing your application. You use release mode when you want to build a release version of your application that you can distribute directly to users or publish on an application marketplace such as Google Play."
If you are in debug mode you do the following ...
A. Open terminal and type:
keytool -exportcert -alias androiddebugkey -keystore path_to_debug_or_production_keystore -list -v
Note: For Eclipse, the debug keystore is typically located at ~/.android/debug.keystore...
B. when prompted for a password simply enter "android" ...
C. If you are in Release mode follow the instructions on...
http://developer.android.com/tools/publishing/app-signing.html <-- this link pretty much explains everything you need to know.
based on #EliuX answer, Latest tools compatible with app bundle
echo y | keytool -genkey -keystore ./android.jks -dname "n=Mark Jones, ou=JavaSoft, o=Sun, c=US" -alias android -keypass android -storepass android -keyalg RSA -keysize 2048 -validity 2000
For your build.gradle
signingConfigs {
debug {
storeFile file('android.jks')
keyAlias 'android'
keyPassword 'android'
storePassword 'android'
}
}
You can create your keystore by exporting a signed APK. When you will try to export/build a signed APK, it will ask for a keystore.
You can choose your existing keystore or you can easily create a new one by clicking create new keystore
Here a link very useful and well-explained of how to create your keystore and generate a signed APK
THis link explained how to do it with Android Studio, but if I remember, it is pretty similar on Eclipse
WATCH OUT
Once you generate your keystore, keep it somewhere safe because you will need it to regenerate a new signed APK.
How do I export a project in the Android studio?
I'd like to suggest automatic way with gradle only
** Define also at least one additional param for keystore in last command e.g. country '-dname', 'c=RU' **
apply plugin: 'com.android.application'
// define here sign properties
def sPassword = 'storePassword_here'
def kAlias = 'keyAlias_here'
def kPassword = 'keyPassword_here'
android {
...
signingConfigs {
release {
storeFile file("keystore/release.jks")
storePassword sPassword
keyAlias kAlias
keyPassword kPassword
}
}
buildTypes {
debug {
signingConfig signingConfigs.release
}
release {
shrinkResources true
minifyEnabled true
useProguard true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
...
}
...
task generateKeystore() {
exec {
workingDir projectDir
commandLine 'mkdir', '-p', 'keystore'
}
exec {
workingDir projectDir
commandLine 'rm', '-f', 'keystore/release.jks'
}
exec {
workingDir projectDir
commandLine 'keytool', '-genkey', '-noprompt', '-keystore', 'keystore/release.jks',
'-alias', kAlias, '-storepass', sPassword, '-keypass', kPassword, '-dname', 'c=RU',
'-keyalg', 'RSA', '-keysize', '2048', '-validity', '10000'
}
}
project.afterEvaluate {
preBuild.dependsOn generateKeystore
}
This will generate keystore on project sync and build
> Task :app:generateKeystore UP-TO-DATE
> Task :app:preBuild UP-TO-DATE
If you don't want to or can't use Android Studio, you can use the create-android-keystore NPM tool:
$ create-android-keystore quick
Which results in a newly generated keystore in the current directory.
More info: https://www.npmjs.com/package/create-android-keystore
Related
I get the title and the text below when I try and fail to build an .aab file using flutter build appbundle:
java.util.concurrent.ExecutionException: java.lang.RuntimeException: jarsignerfailed with exit code 1 :
jarsigner: Certificate chain not found for: keystore. keystore must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.
I had to reset my signing key. The google developer support had me generate a new .jks file with the following command line which I ran from within my project folder:
keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks
He then instructed me to convert this file into a .pem file using this command:
keytool -export -rfc -alias upload -file upload_certificate.pem -keystore keystore.jks
I then emailed him the upload_certificate.pem file. I immediately noticed that the keystore.jks file was red in the sidebar and I get this upon clicking on it:
"The file 'keystore.jks' is not associated with any file type. Please define the association:"
The .pem file is also red, but clicking on it shows the text that makes up the key.
Do I need to reset the signing key again and do something different? Is there a way to fix the issue causing this error?
As dumb as this may sound, I spent 24 hours on this and all I had to was enter flutter clean
You have keyAlias=keystore in your key.properties while it looks like the alias you created is named upload (see in your keytool export command).
Repleace with keyAlias=upload and that should work if your password is correct.
I change my PC and I'm trying to update my app. I download a hole code from GIT but aplications now have different SHA1. How to change it ? There is an easy way ?
Please go through this thread
This is for the app that you have updated it in play store initially and now you are going to update it.
I believe You are talking about app signing with Your developer key in debug mode.
When its built on different PC it is signed with different key.
To avoid this You should be using key generate for project.
You can generate this using keytool:
keytool - genkey -v -keystore <filename> -alias <alias> -keyalg RSA -keysize 2048 -validity <validity in days, more than 25 years>
Then use signConfig in Your build.gradle file:
android {
signingConfigs {
debug {
storeFile file("location of your .keystore file")
storePassword "password for keystore"
keyAlias "alias of the key"
keyPassword "password for the key"
}
}
So simply use earlier certificate to build the new project.
Steps:
1. Open Project Structure.
2. Add Signing
3. Provide the path of earlier keystore.
android_id = android.provider.Settings.Secure.getString(context.getContentResolver(), Secure.ANDROID_ID).toString();
didsha1 = HashingFunctions.sha1(android_id);
you can change sha1 here by assigning some text
First Step
Go your C drive open Program File ->Open JAVA Folder ->Open Bin and DoubleClick on jarsigner.exe
Then Open Cmd
Go to C:\Program Files\Java\jdk1.8.0_191\bin Then Enter
Then Go
C:\Program Files\Java\jdk1.8.0_191\bin>keytool -list -keystore "F:\BTG UPDATE BUILD\Beyond_The_Game.jks"
Enter
JUST Show Enter Kaystoer Password ***** enter your PAssword enter finally Your Release SHA key Getting you
Thank YOU
Our android project consists of mobile and wear app ( wear app is under development) and we are trying to release the mobile app. When we try to generate signed apk we get this follow message :
Error:Execution failed for task ':wear:packageRelease'.
> com.android.ide.common.signing.KeytoolException: Failed to read key
toyanathpatro from store "/home/adventure/toyanath_patro_key/toyanath_patro_key":
No key with alias 'toyanathpatro' found in keystore /home/adventure/toyanath_patro_key/toyanath_patro_key
As it reads it says failed task for :wear:packageRelease where in reality we are selecting just the mobile while choosing for signing the apk.
Can anyone point out my blunder ? Thanks in advance.
The problem seems to be with the wrongly spelled key alias
In my case the alias should have been toyanath patro where I wrongly tried to use toyanathpatro . So the best suggestion would be:
Don't use space or invisible character in the key alias. as far as possible
There is a small selection button (3 horizontal dots) on the right side of key alias editable field. Use that button to find the alias which resides in that signature file.
In your build.gradle you have defined a signing config that it's pointing to a keystore that it's not in your code base.
Something similar to this.
android {
...
buildTypes {
release {
signingConfig signingConfigs.staging
...
}
}
signingConfigs {
defaultSignature {
keyAlias 'default'
keyPassword 'password'
storeFile file('default-keystore.jks')
storePassword 'password'
}
}
}
In my case android studio by default create alias 'key0' and it is the only alias in the file.
My fast solution: Create new key file from android studio with alias that You want. Use that new created file with "Generated Signed APK". If all goes well You could run app with properties set up in "Project Structure".
After generating keystore with-
keytool -genkeypair -v -keystore my-key.keystore -alias my-alias -keyalg RSA -
keysize 2048 -validity 10000
You should use exact name of alias in gradle.properties :-
MYAPP_UPLOAD_STORE_FILE=my-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-alias <------this name
MYAPP_UPLOAD_STORE_PASSWORD=***
MYAPP_UPLOAD_KEY_PASSWORD=***
I had a sticky configuration which I could not get rid of. Even though I had changed the alias in the signing configuration window, it kept giving me the error "Could not find alias" with the original (wrong) alias that I first entered. I searched manually and found a file on path...
[project]/android/app/build/intermediates/signing_config/release/out/signing-config.json
...which contained the original (wrong) alias I first entered. Deleted the file and built/signed the app again. Hope it helps someone.
Build -> Rebuild project
It seems old key names are cached.
If you had the .Jks file before then you can get alias name by typing this command
keytool -v -list -keystore .jks
or
keytool -v -list -keystore .keystore
then you will have to type the password and you will get the alias name by that alias name you can create your signed release file easily.
My problem was that I lost my keys and when I contacted google for making a new key I made a new one with an alias name that I don't know so to solve this in your root android project cd app and paste this command keytool -v -list -keystore yourkeystore.jks don't forget to replace the yourkeystore.jks with your key you will get output we need only the Alias name copy this alias name and past it in your key.properties file like this
storePassword=YourPassword
keyPassword=YourPassword
keyAlias=AliasNameCopiedFromLastStep
storeFile=KeyStorePath
Click Build>Edit library and dependencies .
Then click plus button in signing tab. Key Alias is as same as Alias Key while generating signed apk build.
I initially used key0 for building. It failed with 'Errors while building APK'. Next time, I changed it to 'key1' to work and it worked.
Do not use capital keys for password. It's worked for me.
For generating .jks keys ,
keytool -genkey -alias myKeyStore -keyalg RSA -keystore "C:\apk\fastmoneyv1.jks"
If you are use this code when creating key
" keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload"
You have to update "keyAlias" property from key.properties
from: keyAlias=key
to: keyAlias=upload
in my case i had my keystore files already generated. I was updating my app and when i generated signed apk, i was creating new key_alias. Instead i choosed existing key alias from my keystore files and it's been resolved :)
in my case i have space on the right of the alias and you don't see that space make sure to hover is with the mouse
My issue was that I was using the "my-key-alias" instead of "key0" as the alias name so I had to check to confirm the actual key alias name keytool -v -list -keystore yourkeystore.jks and changing MYAPP_UPLOAD_KEY_ALIAS=key0 in the app/gradle.properties file instead of MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
I am trying to generate apk for releasing on Google play. I am following these steps https://facebook.github.io/react-native/docs/signed-apk-android.html
Step 1) I ran this command
$ keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
It asked me question which I answered and got the my-release-key.keystore file generated
I placed the my-release-key.keystore file under the android/app directory in your project folder.
Now it says:
Edit the file ~/.gradle/gradle.properties and add the following (replace ***** with the correct keystore password, alias and key password),
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=*****
MYAPP_RELEASE_KEY_PASSWORD=*****
Now there was no file previously in /root/.gradle/gradle.properties so i created a new file and added the above 4 constant and there values.
Also it tells (replace ***** with the correct keystore password, alias and key password )
This step is most confusing for me, as there is no ***** in alias field. And when I generated my-release-key.keystore file I din't get any alias
So what I should put in place of my-key-alias ?
What is basically my-key-alias?
other than the 2 passwords i entered, the keytool command generated something like this
CO=Dev Abhi, OP=The Awesome Coder, L=The Awesome Coder, M=Delhi, SP=Delhi, M=IN
are the above the alisa?
so do i need to replace things like
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=CO=Dev Abhi, OP=The Awesome Coder, L=The Awesome Coder, M=Delhi, SP=Delhi, M=IN
MYAPP_RELEASE_STORE_PASSWORD=password1
MYAPP_RELEASE_KEY_PASSWORD=password2
and also Is the real path for ~/.gradle/gradle.properties /root/.gradle/gradle.properties ??
Finally I was able to generate signed apk. So, the thing I was missing -
when you fire the command
$ keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
after option -alias we mention any name/term 'my-key-alias'. that's actually what we need to remember and will have to use same term like this in later step
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
rest of the things are as per documentation. But, I still feel that generating signed apk part could have been made more easy to understand bay react native team. If any one face this same issue please get in touch via http://customphpscript.com
Not sure if this will help you, but I was having the exact same issue. My problem ended up being that the file I was editing ~/.gradle/gradle.properties isn't the file in your project directory but the one in the root directory of your operating system. Once I moved the variables to that location, I was able to generate a signed apk!
I'm here signed my Map application with release key with the help of this link
http://developer.android.com/guide/publishing/app-signing.html#cert
after generating debuging key next step is to generate Release map key by signing with the Certificate. i'm doing these steps which works fine but in end jarsigner is unable to find my NooYawk.apk file.
what should i do further.
admins-Mac-mini:.android David$ keytool -genkey -v -keystore
fureleasekey.keystore -alias fashion -keyalg RSA -keysize 2048
-validity 10000
Next is:-
admins-Mac-mini:~ David$ keytool -genkey -v -keystore
maprelease.keystore -alias maps -keyalg RSA -keysize 2048 -validity
10000 Enter keystore password: Re-enter new password: What is your
first and last name? [Unknown]: m What is the name of your
organizational unit? [Unknown]: h What is the name of your
organization? [Unknown]: k What is the name of your City or
Locality? [Unknown]: le What is the name of your State or Province?
[Unknown]: we What is the two-letter country code for this unit?
[Unknown]: sd Is CN=m, OU=h, O=k, L=le, ST=we, C=sd correct? [no]:
yes
Next is:-
Generating 2,048 bit RSA key pair and self-signed certificate
(SHA1withRSA) with a validity of 10,000 days for: CN=m, OU=h, O=k,
L=le, ST=we, C=sd Enter key password for (RETURN if same as
keystore password): Re-enter new password: [Storing
maprelease.keystore]
Next is:-
admins-Mac-mini:~ David$ jarsigner -verbose -sigalg MD5withRSA
-digestalg SHA1 -keystore maprelease.keystore NooYawk.apk maps Enter Passphrase for
keystore: jarsigner: unable to open jar file:
NooYawk.apk
Thanks in advance.
Unless NooYawk.apk is in your current working directory, you need to supply a full path to the APK file.
Cut the Keystore file from android folder to build-->outputs-->apk and paste it, then run the jarsigner command
You need to provide a complete path to the directory of your apk file i.e /USER/DEVELOP/PATH_TO_APK (on a mac osx)
One experience I had is I needed to run jarsigner in the same folder where not just the .apk file but also the related .ap_ and .apk.d files etc were present. So I copied the keystore to the bin output folder and ran jarsigner in that folder. Then things worked.
You should try running the command in your apk path. Copy the unsigned keystore file to the apk path first.