Gradle Configuration Buildconfig Detailed _gradle

Source: Internet
Author: User

Buildconfig the previous article has a brief mention, this time describes in detail what each command represents.

This feature is very powerful and we can set up some key-value pairs here, which are different for values under apk of different compilation types, for example, we can define different servers for debug and release two environments.

Let's take a look at the simple release mode.

Buildtypes {release
         {
          //whether to open confusion
            minifyenabled true      
            //confuse file    
            proguardfiles getdefaultproguardfile (' Proguard-android.txt '), ' Proguard-rules.pro '
         }
   }

The corresponding build is like this:

You may ask, no debug version is set, why there is a assembledebug, in fact you do not set release configuration, Assemblerelease also exist, because Debug,release is the default configuration.

We can add some other type. For example, beta for peacetime development, this command to play out the package, log switch on, and no confusion, convenient positioning error. Proguard is used to test the upcoming release, the log switch is on, the code is confusing, the main validation code is confusing and there are exceptions, and you can locate errors based on the log.

Buildtypes {release
        {
            minifyenabled true
            proguardfiles getdefaultproguardfile (' Proguard-android.txt ') , ' Proguard-rules.pro '

        }


        Beta {
            minifyenabled true

        }
        proguard{
            minifyenabled true
            Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '

        }
    }

Look at our task again and find out more of these tasks

Publish APK package, need to sign, very simple only need to set up under the corresponding BuildType Signingconfig

 signingconfigs {keyalias ' keystore ' keypassword ' 111111 ' sto Repassword ' 111111 ' storefile file ('/users/keystore/documents/app/stone.keystore ')}} buildty pes {release {minifyenabled true proguardfiles getdefaultproguardfile (' proguard-android. TXT '), ' Proguard-rules.pro ' Signingconfig signingconfigs.release} beta.initwith (BUILDTYPES.D Ebug) Beta {minifyenabled true signingconfig signingconfigs.release} PR oguard{minifyenabled false Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguar D-rules.pro ' Signingconfig Signingconfigs.release}} 

Signingconfig this gradle api,signingconfigs.release signingconfigs corresponds to the Signingconfigs task, this name can not be modified, according to write on the line The release in Signingconfigs.release is custom, you can define it freely, or you can define multiple sets of signatures according to BuildType, generally for convenience, use a set of signatures on OK

Other properties on BuildType please check the website

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.