3张图片让你彻底明白app目录下build.gradle中配置的用法和含义

来源:互联网 发布:电钢琴推荐知乎 编辑:程序博客网 时间:2024/04/25 15:22

as中的app目录下通常要配置一大堆东西,好多东西莫名又费解,这里参考几个博客内容整理了一下,都有注释,希望大家能一起理解,满满的干货。
直接上图:
这里写图片描述
这里写图片描述
这里写图片描述

看完上面图片后,应该对很多配置都知晓到底是做什么用的了….

下面上配置代码:

apply plugin: 'com.android.application'android {    compileSdkVersion 24 //最高API等级    buildToolsVersion "25.0.0" //buildtools的版本号    defaultConfig {  //默认配置        applicationId "com.example.user.launchmode" //应用id,相当于包名        minSdkVersion 17 //最小API等级        targetSdkVersion 24//编译API等级        versionCode 1//版本号        versionName "1.0"//版本名称        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" //单元测试       /**dex突破65535的限制*/        multiDexEnabled true        /**这里用到UMENG 多渠道打包*/        manifestPlaceholders=[UMENG_CHANNEL_VALUE: "channel_name"]    }    /**执行lint检查,有任何的错误或者警告提示,都会终止构建,可以关闭*/    lintOptions{        abortOnError false    }   /**签名配置*/    signingConfigs{        debug{            /**app keystore路劲*/            storeFile file("../yourapp.keystore")        }        release{            storeFile file("../yourapp.keystore")            /**打包签名时在build里面的key store password*/            storePassword "123456"            /**打包签名时,build里面的keyAlias*/            keyAlias "launch"            /**打包签名时,build里面的key password*/            keyPassword "123456"        }    }    buildTypes { //构建类型        release { //正式版配置            /**是否开启混淆 true表示开启*/            minifyEnabled true            /**是否删除无效Resource true表示删除*/            shrinkResources true            /**不显示Log*/            buildConfigFields "boolean","LOG_DEBUG","false"            /**Zipalign优化*/            zipAlignEnabled true            /**混淆配置文件 和minifyEnabled一起使用*/            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'            /**签名*/            signingConfig signingConfigs.release        }        debug{            /** 和s上面release设置一样*/        }    }    /**友盟多渠道打包设置*/    productFlavors{        xiaomi{}        _360{}        baidu{}        wandoujia{}    }    /**和上面多渠道打包配合使用的,这是一种简写方法*/    productFlavors.all{        flavor ->flavor.manifestPlaceholders=[UMENG_CHANNEL_VALUE:name]    }}/**依赖配置*/dependencies {    /**依赖本地二进制*/    compile fileTree(dir: 'libs', include: ['*.jar'])    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {        exclude group: 'com.android.support', module: 'support-annotations'    })    /**依赖远程二进制*/    compile 'com.android.support:appcompat-v7:24.2.1'    testCompile 'junit:junit:4.12'    /** 依赖的moudle名称*/    compile project(':moudle名称')}

一起努力,多分享干货文章,加油…….

0 0
原创粉丝点击