Android Gradle configuration Option Collection

Source: Internet
Author: User

Let Gradle into the build Android app plugin apply plugin: ' com.android.application '//Custom variable Customprop {minsdkversion prop2 "foo"}//Custom Volume def CUSTOMPROP2 = ["Targetsdkversion":, "Prop2": "Bar"];//custom variable//Generate build number automatically by date def calendar = Calendar.getinstance (        );d EF TT = String.Format ("%d%02d%02d%02d", Calendar.get (Calendar.year), Calendar.get (Calendar.month) +1, Calendar.get (Calendar.day_of_month), Calendar.get (Calendar.hour_of_day));//Read local.properties file def Properties p roperties = new Properties () properties.load (Project.rootProject.file (' local.properties '). Newdatainputstream ())            Android {compilesdkversion buildtoolsversion "24.0.0"//Signature option Signingconfigs {demosigncfg { Keyalias ' demo '//Read configuration Keypassword properties.getproperty ("Key.password") StoreFile F Ile (' Demo.keystore ') Storepassword properties.getproperty ("Key.password")}}//Compile Options compileopt ions {//using jdk1.8 to compile SOURCEcompatibility javaversion.version_1_8 targetcompatibility Javaversion.version_1_8}//code check OPTION LintOptions    {//Check Release build Checkreleasebuilds RootProject.ext.checkReleaseBuilds//Encounter error stop abortonerror false         }//Packaging options Packagingoptions {//Removed files exclude ' meta-inf/license ' Exclude ' meta-inf/license.txt '        Exclude ' meta-inf/notice ' Exclude ' meta-inf/notice.txt '}//Resource packaging options Aaptoptions {//uncompressed files Nocompress ' foo ', ' bar '//filter file Ignoreassetspattern '!. Svn:!. Git:!. ds_store:!*.scc:.*:<dir>_*:! Cvs:!thumbs.db:!picasa.ini:!*~ "}//Compile Dex option dexoptions {//stack memory up to 4g javamaxheapsize" 4g "}// Configure configurations {//Remove all Com.android.support:support-annotations dependent all*.exclude group: ' Com.android.s    Upport ', module: ' Support-annotations '; }//Default global configuration option Defaultconfig {ApplicationID "com.example.gradle_test" Minsdkversion cuStomprop.minsdkversion targetsdkversion customprop2.targetsdkversion//Use the generated version number Versioncode INTEGER.P Arseint (TT) Versionname placeholder for "1.0"//manifest: &lt, .... android:label= "${activitylabel}"/> Manif Estplaceholders = [Activitylabel: "DefaultName"]}//build Variant, flavor and Defaultconfig type same productflavors {//change        Type 1 Flavor1 {packagename "Com.example.flavor1" Versioncode} flavor2 {            }}//configuration of various directories Sourcesets {//Primary main {manifest.srcfile ' androidmanifest.xml ' Java.srcdirs = [' src '] resources.srcdirs = [' src '] aidl.srcdirs = [' src '] renderscript. Srcdirs = [' src '] res.srcdirs = [' res '] assets.srcdirs = [' assets '] jnilibs.srcdirs = [' l IBS ']}//test resource Path Instrumenttest.setroot (' tests ') debug.setroot (' Build-types/debug ') rel Ease.setroot (' Build-typeS/release ')}//Build type Buildtypes {//debug type (just a name) debug {//app id suffix: Com.example.ap            P.debug applicationidsuffix ". Debug"}//Release type (just a name) release {//Turn off obfuscation Minifyenabled false//Use of obfuscation files Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' pro Guard-rules.pro '//Signature options Signingconfig Signingconfigs.demosigncfg
Remove Useless resources
        Shrinkresources true//version name suffix Versionnamesuffix ". 0"//Specify Package file name appli           Cationvariants.all {variant-variant.outputs.each {output, def outputFile = Output.outputfile if (outputFile! = null && outputFile.name.endsWith ('. apk ')) {//output APK name is called boohee_v1.0_2015-01- 15_wandoujia.apk def fileName = "Apk_v${defaultconfig.versionname}_${releasetime ()}_${variant.productflavors[0 ].name}.apk "output.outputfile = new File (outputfile.parent, FileName)}} Filter Abi library NDK {//package only the following platforms for so Abifilters "x86", "armeabi-v7a", "Armeabi", ' MIPS ' }}//Custom Jnidebug {//inherit from the above Debug. Initwith Debug Applicationidsuffix ". Jnidebug" Jnidebuggable True}}//Dependent warehouse Reposit ories {maven {URL "Https://jitpack.io"}}}//Dependency Tubedependencies {//compile/run-time dependent on compile Filetree (dir: ' Libs ', include: [' *.jar '])//$rootProject. Ext means the project's build.gr. Adle defines an ext variable compile ("Com.android.support:design: $rootProject. Ext.supportversion") {//does not refer to the following package Exclud E module: ' support-v4 ' Exclude module: ' Appcompat-v7 '//Transitive false}//test dependent test Compile ' junit:junit:4.12 '//externally supplied, not packaged provided ' com.android.support:appcompat-v7:23.4.0 '//falvor1 required dependencies, F1compi Le, f1provided ... flavor1compile ' com.android.support:appcompat-v7:24.0.0 '}//clean up the tasktask of the built resources (TYPE:DELETE) {Delete Rootproject.builddir}

If there are errors in the above configuration, please also indicate

Android Gradle configuration Option Collection

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.