"Gradle authoritative Guide"--Custom Android Gradle Project

Source: Internet
Author: User
Tags addall

NO1:

Minsdkversion

 Public void minsdkversion (int  minsdkversion) {    setminsdkversion (minsdkversion);} -----------------------publicvoid  setminsdkversion (@Nullable String minsdkversion) {    Setminsdkversion (Getapiversion (minsdkversion));}  Public void minsdkversion (@Nullable String minsdkversion) {    setminsdkversion (minsdkversion);}

No2:

Android code version corresponding table

No3:

Versioncode-Build number

@NonNull  Public productflavor Setversioncode (Integer versioncode) {    = versioncode;     return  This ;} @Override @nullablepublid Integer Getversioncode () {    return  mversioncode;}

No4:

versionname-version name

@NonNull  Public productflavor setversionname (String versionname) {    = versionname;     return  This ;} @Override @nullable public String getversionname () {    return  Mversionname;}

NO5:

Testapplicationid-app's package name

@NonNull  Public productflavor Settestapplicationid (String applicationid) {    = ApplicationID;     return  This ;} @Override @nullable public String Gettestapplicationid () {    return  Mtestapplicationid;}

NO6:

Testinstrumentationrunner-runner used when configuring unit tests

@NonNull  Public productflavor Settestinstrumentationrunner (String testinstrumentationrunner) {    =  Testinstrumentationrunner;     return  This ;} @Override @nullable public String Gettestinstrumentationrunner () {    return Mtestinstrumentationrunner ();}

No7:

signingconfig-Configuring the default signature information

@Override @nullable  Public signingconfig Getsigningconfig () {    return  msigningconfig;} @NonNull public productflavor setsigningconfig (signingconfig signingconfig) {    =  Signingconfig;     return  This ;}

No8:

Proguardfile-Confusing the configuration file used

 Public void projuardfile (@NonNull Object projuardfile) {    getprojuardfiles (). Add (Project.file (Projuaardfile));}

No9:

proguardfiles-Multiple configuration files accepted at the same time

 Public void proguardfiles (@NonNull object...proguardfilearray) {    getproguardfiles (). AddAll (Project.files ( Proguardfilearray). GetFiles ());}

No10:

Configuring signature Information

signingconfigs{    release{        storefile file ("Myreleasekey.keystore")        "Password"          "Myreleasekey"        "password"    }    debug{        storefile file (" Mydebugkey.keystore ")        " password "        " Mydebugkey        "" Password "     }}

StoreFile: Signing certificate file

Storepassword: Password for the signing certificate file

Storetype: Type of Signing certificate

Keyalias: Secret key alias in signing certificate

Keypassword: The password for the secret key in the signing certificate

Note: The signature of the debug mode is already configured, using the automatic debug certificate generated by the Android SDK, usually located in the. /.android/debug.keystore

Call

defaultconfig{    "org.flysnow.app.example82    " 1              "1.0"    signingconfig signingconfig.debug}

Or

buildtype{    release{        signingconfig signingconfigs.release    }    debug{        signingconfig Signingconfig.debug    }}

NO11:

Applicationidsuffix-Used to configure the suffix based on the default ApplicationID

@NonNull  Public Baseconfigimpl setapplicationidsuffix (@Nullable String applicationidsuffix) {    =  Applicationidsuffix;     return  This ;} @Override @nullable public String Getapplicationidsuffix () {    return  Mapplicationidsuffix;}

No12:

debuggable-Used to configure whether to generate an apk for debugging

@NonNull  Public BuildType setdebuggable (boolean  debuggable) {    = debuggable;     return  This ;} @Overridepublicboolean  isdebuggable () {    return mdebuggable | | mtestcoverageenabled;}

NO13:

jnidebuggable-Used to configure whether to generate an apk for debugging JNI code

@NonNull  Public BuildType setjnidebuggable (boolean  jnidebugbuild) {    = jnidebugbuild;     return  This ;} @Overridepublicboolean  isjnidebuggable () {    return  mjnidebuggable;}

NO14:

minifyenabled-Used to configure whether Proguard obfuscation is enabled

@NonNull  Public BuildType setminifyenabled (boolean  enabled) {    = enabled;     return  This ;} @Overridepublicboolean  isminifyenabled () {    return  mminifyenabled;}

NO15:

multidexenabled-Used to configure whether the BuildType enables automatic splitting of multiple Dex features

@Override @nullable  Public Boolean getmultidexenabled () {    return  mmultidexenabled;}  Public void setmultidexenabled (@Nullable Boolean multidex) {    = multidex;}

NO16:

Proguardfile

@NonNull  Public buildtype projuardfile (@NonNull Object proguardfile) {    getproguardfiles (). Add (Project.file (proguardfile) );     return  This ;}

NO17:

Proguardfiles

@NonNull  Public buildtype projuardfiles (@NonNull Object ... proguardfilearray) {    getproguardfiles (). AddAll (Project.files ( Proguardfilearray). GetFiles ());     return  This ;}

NO18:

Shrinkresources

@Override  Public Boolean isshrinkresources () {    return  thrinkresources;}  Public void setshrinkresources (boolean  shrinkresources) {    this. Shrinkresources = shrinkresources;}

NO19:
Signingconfig

@NonNull  Public buildtype setsigningconfig (@Nullable signingconfig signingconfig) {    = signingconfig;     return  This ;} @Override @nullable public signingconfig getsigningconfig () {    return  Msigningconfig;}

NO20:

Each buildtype generates a sourceset and generates the corresponding assemble tasks, such as Assemblerelease or Assembledebug

NO21:

Code obfuscation can not only optimize our code, make the APK package smaller, but also confuse our original code

NO22:

 Public File getdefaultprojuardfile (String name) {    = sdkhandler.getandchecksdkfolder ();     return New File (sdkdir,sdkconstants.fd_tools + File.separatorchar + sdkconstants.fd_proguard + File.separatorchar + name);}

The Android SDK defaults to two Proguard profiles, Proguard-android.txt and Proguard-android-optimize.txt, one without optimizations and one with optimizations.

No23:

android{    buildtypes{        release{            true        }        debug{                    }    }} 
@NonNull  Public BuildType setzipalignenabled (boolean  zipalign) {    = zipalign;     return  This ;} @Overridepublicboolean  iszipalignenabled () {    return  mzipalignenabled;}

"Gradle authoritative Guide"--Custom Android Gradle Project

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.