When building with Gradle, keep sensitive information, such as passwords, out of Build.gradle

Source: Internet
Author: User
Tags version control system

password You need to define the app when you do the version release build.gradle signingConfigs . You should avoid the following at this point:

don't do this . This will appear in version control.

Signingconfigs {    release {        storefile file ("Myapp.keystore")        "password123"          "thekey        " "password789"    }}

Instead, create a file that does not join the version control system gradle.properties .

keystore_password=Password123key_password=password789

The file is automatically introduced by Gradle, which you can buld.gradle use in the file, for example:

Signingconfigs {    release {        try  {            storefile file ("Myapp.keystore")            Storepassword keystore_password            "Thekey"            keypassword key_password        }        catch  (ex) {            thrownew invaliduserdataexception ("You should define Keystore_ PASSWORD and Key_password in Gradle.properties. " )        }    }}

A complete example:

Apply plugin: ' Com.android.application 'Android {compilesdkversion22buildtoolsversion"22.0.1"Defaultconfig {ApplicationID"Com.example.jack.umengfeedback"minsdkversion15targetsdkversion22Versioncode1Versionname"1.0"} signingconfigs {release {Try{storefile file ("Myapp.keystore") Storepassword Keystore_password Keyalias"Thekey"Keypassword Key_password}Catch(ex) {Throw NewInvaliduserdataexception ("should define Keystore_password and Key_password in Gradle.properties."))}}} buildtypes {release {minifyenabledfalseproguardfiles Getdefaultproguardfile (' Proguard-android.txt '), ' Proguard-rules.pro '}}}repositories {flatdir {dirs' Libs '//This is the we can find the. aar file in Libs folder}}dependencies {Compile filetree (dir:' Libs ', include: [' *.jar ']) Compile' com.android.support:appcompat-v7:22.1.1 'Compile project (': Umenglib ')    //Dependent AARCompile (name: ' Kalelibrary ', ext: ' AAR '))}

When building with Gradle, keep sensitive information, such as passwords, out of Build.gradle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.