Home > database >  keep my project key.properties and .jks file in Github
keep my project key.properties and .jks file in Github

Time:03-30

I want to keep my project key.properties and .jks file in GitHub, but whenever I committed after generating these files, these files don't commit.

I know it might be risky to keep these files on GitHub but my repositories are private and only my collages have access to them.

So, I want to keep these files in my GitHub repositories.

any help regarding this will be highly appreciated.

CodePudding user response:

It's indeed very risky to commit those files.

If you really want to commit them and can't here are two possible reasons:

  • You might have a rule in your .gitignore that says to not commit those files.
  • You might have an extension/bot on your Github Repository to check if these files are committed (GitGardian for example) and you might want to remove it for this repository in this specific case.

CodePudding user response:

Check android/.gitignore, it has the following lines by default:

key.properties
**/*.keystore
**/*.jks

Remove or comment them.

CodePudding user response:

You need to write below code in build.gradle

signingConfigs {
        release {

            file("keystore/signin.properties").with { propFile ->
                if (propFile.canRead()) {
                    def properties = new Properties()
                    properties.load(new FileInputStream(propFile))
                    storeFile file("keystore/${properties['storeFile']}")
                    storePassword properties['storePassword']
                    keyAlias properties['keyAlias']
                    keyPassword properties['keyPassword']
                } else {
                    println "Unable to read signing.properties"
                }
            }
        }
    }

And save your jks and .properties like below screen in keystore folder

enter image description here

Also write your jks detail in signin.properties like below

enter image description here

  • Related