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