Can I use the same keystore file to sign two different applications?
Asked Answered
S

7

109

I have to upload a new application, It's just the design that's a little different. Yesterday I generated the keystore file to sign application. Can I use the same?

Sigismundo answered 7/10, 2011 at 9:36 Comment(2)
yes you can (also, did you try before asking?)Chaparral
It will be useful for u have multiple applications in a certain organization and making custm permissions by securely but alias name should be differentColumbia
C
126

You can use that keystore for any number of applications.

No need to generate a new keystore.

Clove answered 7/10, 2011 at 9:42 Comment(4)
And for 'Alias', what should i write?Scribner
A keystore CONTAINS the public/private keypairs that make up a signing certificate. One keystore can contain many keypairs. An 'alias' is a reference to a particular keypair in the keystore. One keystore can hold all of your keypairs, but you should have one keypair per app. Use the name of the app you are signing as the alias. You can have separate passwords for your keystore and for each keypair within it. You can change these passwords and import/export keypairs from the keystore or add new keypairs to your keystore. This is all done with the command line 'keytool' command. Look it up.Kodak
@Kodak Can new pairs be added to the keystore via a GUI?Trumpetweed
In 2022 also you can use the same Keystore & allies for multiple apps, Playstore has no issue.Headfirst
H
53

I'll make a counter argument to the consensus answer so far.

I agree that for most app authors most of the time, sharing the same keystore/certificate/password between your apps will work fine. The critical thing is to use "the same certificate throughout the expected lifespan of your applications" so the app can upgrade itself.

But I can think of one very good reason to have separate keystores for separate apps or families of apps. If you think you might ever want to sell an app to someone else for them to publish as an upgrade to the original, you'll have to share your one-and-only keystore and password with them to do so. Probably not a huge issue but a bit of worry to you and, perhaps, a due diligence issue to a big-enough buyer.

Also, I really don't read the same line in the documentation the same way as @ol_v_er does. I think the current line:

You should sign all of your apps with the same certificate throughout the expected lifespan of your applications.

(note the lack of a comma in the current version) is simply emphasizing that the 'lifetime' recommendation applies to all apps, not actually directing you to use the same certificate for all of your apps.

Heptagonal answered 3/10, 2014 at 20:5 Comment(2)
Keeping separate keystores for each app should be the way to go!Wattage
The recommendation is to use a different file for each app, right? What happens if you use the same keystore file for more than one app, though? It seems to cause some issues with Firebase/Google services. I guess it's impossible to use a new one (a different one for each app) if it's already done, right?Archpriest
C
50

The official documentation tells us:

In general, the recommended strategy for all developers is to sign all of your applications with the same certificate, throughout the expected lifespan of your applications. There are several reasons why you should do so ...

https://developer.android.com/studio/publish/app-signing.html#considerations

So yes, try to sign all of your applications with the same certificate.

Curren answered 7/10, 2011 at 10:6 Comment(5)
And for 'Alias', what should i write?Scribner
To make it simple, also use the same for all your apps.Curren
My question is now is there any problem to use different keystore and certificate for different applicationFescennine
@Lucian absolutely no problem to do that. It's just a bit more complex to manage. If you keep your certificates whith the source code, it's ok.Curren
The section in the documentation you quoted removed the terminology "all of your applications" and replaced it with "your app"Invest
C
33

I want to add some clarification here, because this question and the answers provided lead to confusion for me. It is crucial to understand what a keystore actually is.

A keystore is just a means to securely store the public/private key pair which is used to sign your Android apks. So yes, you can use the same keystore to sign multiple apks, without a problem. You can also use the same alias (each alias is a certificate) to sign multiple apks, and it will work. It has security implications, however. If your single alias is compromised, then all of your apps will have been compromised.

However, if you intend to sell the rights to your apps one day, then using the same alias for all of your apps may not be a good idea. However, using the same keystore, provided you use a different alias for each apk, may not necessarily be a bad option. I'm sure there is a way that you can move a certificate from one keystore to another, so that you can securely give the necessary keys for only that certificate to your buyer.

To make it very clear, a keystore is just that, a storage medium for keys. It plays no actual part in the process of signing an apk, but only serves to store the keys which are actually used to sign the apk.

References:

Understanding keystore, certificates and alias

https://www.digitalocean.com/community/tutorials/java-keytool-essentials-working-with-java-keystores

Camelot answered 11/5, 2016 at 21:33 Comment(5)
Please don't post identical answers to multiple questions. Post one good answer, then vote/flag to close the other questions as duplicates. If the question is not a duplicate, tailor your answers to the question.Baalbek
Apologies. I'm a noob to SO.Camelot
I don't have enough rep to vote for a duplicate. So if you would like to vote the following questions as duplicates, I feel this question is the most appropriate to be the non-duplicate. It is the first rank in Google for the relevant keywords, and has the most relevant answers. #13024009 #14973705 #10515097Camelot
Wait! How can I use the same keystore but with different alias for each app?!Whelk
is this applicable for the app bundle too?Tana
E
9

Of course! You can use the same keystore file as many times you want. It's always better to use the same keystore file for all the applications you develop. That will help if you want to update or modify the application. At that time you need to sign your application with the same key.

Expiatory answered 7/10, 2011 at 9:45 Comment(0)
M
5

Recent Update

If you want to enrol in App signing by google you have to use new different key to sign your apk or bundle otherwise after uploading google console will give you error message saying

You uploaded an APK or Android App Bundle that is signed with a key that is also used to sign APKs that are delivered to users. Because you are enrolled in App Signing by Google Play, you should sign your APK or Android App Bundle with a new key before you upload it

Molt answered 15/10, 2020 at 13:38 Comment(4)
I was able to generate a new key inside android studio apk signing screen. Generate new keystore and alias and it may work. It worked for me.Bakerman
can we opt out this?Impose
I think this error message may be due to a different reason. Because I had the same issue. and it's not related to the keyStore file.Madriene
I used the same Keystore file with the same alias & password, and Playstore has no issue.Headfirst
M
4

I do sign all my apps using the same certificate (keystore). This gives an advantage if i change my mind and want my apps to share their data.

As you might know Android identifies each app with an UID. If all your apps are signed by the same certificate you can request android to assign same user id more than one app and inturn make them run in a single process and share the data.

From android doc android:sharedUserId

android:sharedUserId

The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is set to the same value for two or more applications, they will all share the same ID — provided that they are also signed by the same certificate. Application with the same user ID can access each other's data and, if desired, run in the same process

Medieval answered 22/12, 2016 at 9:14 Comment(1)
Cool comment, didn't knew that thanks! :)Underpainting

© 2022 - 2024 — McMap. All rights reserved.