app目录下的build.gradle详解

xiaoxiao2021-02-28  87

主要参考自《第一行代码》 // 表示这是一个Android程序模块,如果是作为库,就声明为Library'com.android.library' apply plugin: 'com.android.application' android { compileSdkVersion 26 // 编译版本,指用哪个版本的SDK进行编译 buildToolsVersion "26.0.1" //构建工具 //对项目的更多细节进行配置 defaultConfig { applicationId "com.seachal.myapplicationtestlog" minSdkVersion 19 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } //指定生成安装文件的相关配置 buildTypes { //release 闭包用于指定生成正式版安装文件的配置 release { minifyEnabled false //指定是否对项目的代码进行混淆, true 表示混淆, false 表示不混淆。 //proguard-android.txt在默认的SDK目录下,有通用的混淆规则 // proguard-rules.pro 有本项目专用的混淆规则 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } //debug闭包可以忽略不写 } } dependencies { //本地依赖声明,它表示将 libs 目录下所有.jar 后缀的文件都添加到项目的构建路径当中 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:26.+' //com.android.support.constraint 是域名。constraint-layout是组名,用于区分同一公司的不同库。 1.0.2是版本号 compile 'com.android.support.constraint:constraint-layout:1.0.2' //compile project(':helper') //库依赖声明格式,表示依赖了一个叫helper的Library // 声明测试用例库 testCompile 'junit:junit:4.12' }
转载请注明原文地址: https://www.6miu.com/read-71672.html

最新回复(0)