0

I have made two basic (hello world) apps in android studio with different project names and hence different package names as well . say App A in package com.example.first.appA and App B in com.example.second.appB

Still I am getting same signature keys for my above two apps and I am completely clueless on what could be the reason for same key. Somebody please help!

Here is the code snippet I am using to get the signatures from my apps .

PackageInfo packageInfo = this.getPackageManager()

                    .getPackageInfo(this.getPackageName(),

                            PackageManager.GET_SIGNATURES);

            for (Signature signature : packageInfo.signatures) {

                byte[] signatureBytes = signature.toByteArray();

                MessageDigest md = MessageDigest.getInstance("SHA");

                md.update(signature.toByteArray());

                final String currentSignature = Base64.encodeToString(md.digest(), Base64.DEFAULT);

                Log.d("Signature", "Here is the value for SIGNATURE:" + currentSignature);

So when I put this code snippet one by one in both of my apps A and B . I get same value of currentSignature say 478yYkKAQF+KST8y4ATKvHkYibo= in my Log

Note : I have not done any release/ debug mode signing explicitly for my app ,i.e. they should be something by default . (Using android studio)

EDIT After the answers from SO and googling I got the answer that any number of projects you have on your android studio would have same debug key (unless explicitly modified) and you can get different keys for different projects by signing your app.

Community
  • 1
  • 1
eRaisedToX
  • 3,221
  • 2
  • 22
  • 28

2 Answers2

2

By default, all debug variants of the apps have same signature (i.e. the same default certificate is used for signing).

If you want your apps to have different signatures, you'll need to generate a new debug certificate and manually add it to one of the apps.

Related links: How to generate a new keystore. How to change debug keystore.

Community
  • 1
  • 1
Vasiliy
  • 16,221
  • 11
  • 71
  • 127
1

The default debug key is auto-generated by Android Studio and stored on ~/.android/debug.keystore (for Linux/Mac systems), and C:\User\YourUser\.android\debug.keystore for Windows systems.

And this same key will be used on every project on that machine unless you delete the key, which then Android Studio will re-auto-generate a new one the next time it runs.

That is absolutely normal behavior and I honestly don't understand why are you worried with it.

If you need to (for whatever reason) to have different signature keys on debug builds, see this: Android Studio 0.4.+ custom debug keystore

Community
  • 1
  • 1
Budius
  • 39,391
  • 16
  • 102
  • 144