5

What keystore does jenkins use while building android projects.

Since I use Google Sign-in. I need to use the same debug keystore that i use locally. For that purpose,I have overwritten the debug.keystore on the server. However I am still unable to sign in as the keystore is different.

1 Answer 1

4

By default, the Android build system uses a keystore in $HOME/.android/debug.keystore.

If that file does not exist already at build time, it will be automatically generated. So most likely the app is being signed with a completely different keystore on your machine and on the Jenkins machine.

You can resolve this by copying the keystore from your machine to the Jenkins machine, to the user $HOME directory that Jenkins runs as.


Alternatively, you can override the default build system behaviour by explicitly supplying a keystore to use when building a debug version of the app.

This means that, no matter user on which machine builds the app, the same debug keystore will always be used to sign the APK.

For example, you can add a new signingConfig to app/build.gradle:

signingConfigs { debug { // Override the local debug keystore, so that // all builds have consistent certificates storeFile file('../debug.keystore') } } 

This assumes that you've created and checked-in a debug keystore at the root of your project.

This debug keystore must have the same key alias and password as the ones that the Android build system generates, i.e. alias androiddebugkey, password android.

You can use keytool to generate a key with these properties:

keytool -genkey -v -keyalg RSA -keysize 2048 -validity 10000 \ -dname 'CN=Android Debug,O=Android,C=US' -keystore debug.keystore \ -storepass android -alias androiddebugkey -keypass android 
Sign up to request clarification or add additional context in comments.

10 Comments

I dont want to add it to the gradle file.I was hoping of something like shell execution params. And I have replaced that keystore(@ $HOME/.android).However the signatures are not the same.
If the signatures are not the same, then the keystores are not the same. You can verify this with keytool -v -list -keystore ~/.android/debug.keystore -storepass android.
So i compared both the md5s.They are the same.could there be another reason that Google OAuth views them differently?
Are you sure the debug.keystore file is in the right directory (i.e. the ~/.android/ directory of the Jenkins user)? Do the APKs generated on your machine, and by Jenkins have the same certificate fingerprints when you compare with keytool -list -printcert -jarfile app-debug.apk?
The jenkins user does not have a shell or home folder or any of those privilleges.I switched users and searched for a .android folder, and was pointed to the same folder where i have placed the debug keystore
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.