How to make single debug.keystore for whole android team or signing with Gradle

Published by Igor Khrupin on

Problem happens when you have more than one developer in the Android team or you develop project from different computers.

Some APIs or functionality depends on keystore which sign the APK. For example Facebook API.

To make life easier you need keep your debug.keystore same for all your computers/developers.

But, it isn’t solution!

How to make it?

You can keep debug.keystore in your project and link it for signing automatically.
Gradle help with it.

Here is gradle config with current functionality.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    signingConfigs {
        debug {
            storeFile file('../keystore/debug.keystore.jks')
            storePassword "android"
            keyAlias "android"
            keyPassword "android"
        }
        
        release {
            storeFile file('../keystore/release.keystore.jks')
            storePassword "releaseStorePassHere"
            keyAlias "releaseAliasHere"
            keyPassword "releaseKeyPassHere"
        }
    }

    defaultConfig {
        applicationId "com.hrupin.sampleapp"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            minifyEnabled true
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
}

The important part is here:

signingConfigs {
        debug {
            storeFile file('../keystore/debug.keystore.jks')
            storePassword "android"
            keyAlias "android"
            keyPassword "android"
        }
        
        release {
            storeFile file('../keystore/release.keystore.jks')
            storePassword "releaseStorePassHere"
            keyAlias "releaseAliasHere"
            keyPassword "releaseKeyPassHere"
        }
    }

storeFile file(‘../keystore/debug.keystore.jks’) – related path to keystore

Nice coding!


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.