Skip to content

Instantly share code, notes, and snippets.

@maiatoday
Last active April 26, 2017 15:20
Show Gist options
  • Save maiatoday/2df1e24224b9def4fa0b11cd2d5a6ff6 to your computer and use it in GitHub Desktop.
Save maiatoday/2df1e24224b9def4fa0b11cd2d5a6ff6 to your computer and use it in GitHub Desktop.
android signing config solution

in ~/.gradle/gradle.properties APP.signing=/home/user/.signing/appname/prefix

in /home/user/.signing/appname put 2 files prefix.keystore the keystore and a gradle snippet with name prefix.gradle prefix.gradle:

android {
    buildTypes {
        debug {
            buildConfigField 'String', 'BASE_URL', '"https://api-debug.example.com"'
        }
        release {
            buildConfigField 'String', 'BASE_URL', '"https://api.example.com"'
        }

    }

    productFlavors {
        vanilla {
            buildConfigField 'String', 'BASE_OTHER_URL', '"https://api-vanilla.example.com"'
        }
        chocolate {
            buildConfigField 'String', 'BASE_OTHER_URL', '"https://api-chocolate.example.com"'
        }

    }
  signingConfigs {
    release {
      storeFile file(project.property("APP.signing") + ".keystore")
      storePassword "somepassword"
      keyAlias "somealias"
      keyPassword "somepassword"
    }
  }

  buildTypes {
    release {
      signingConfig signingConfigs.release
    }
  }
}

then in the app build.gradle add the following

if(project.hasProperty("APP.signing")
        && new File(project.property("APP.signing") + ".gradle").exists()) {
    apply from: project.property("APP.signing") + ".gradle";
}
@maiatoday
Copy link
Author

Also look at https://hackernoon.com/configuring-android-project-version-name-code-b168952f3323 for auto version numbers and version codes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment