AS:build.gradle笔记
来源:互联网 发布:intouch组态软件下载 编辑:程序博客网 时间:2024/05/17 16:44
build.gradle文件(app目录下)
apply plugin: 'com.android.application'
/**
com.android.application 表示一个应用程序模块(可直接运行)
com.android.library 表示一个库模块(依附于别的应用程序来运行)*///android闭包android { compileSdkVersion 26 //用于指定项目编译的版本
//defaultconfig闭包 更多的细节配置 defaultConfig { applicationId "com.example.lj.lujingtest"//项目包名 minSdkVersion 15 //项目最低兼容的版本 15表示最低兼容到4.0系统 targetSdkVersion 26 //表示在该目标版本上进行过充分的测试 versionCode 1 //指定项目的版本号 versionName "1.0"//指定项目的版本名 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" }
//buildTypes闭包 buildTypes {
//一般包括debug和release debug可以忽略不写
//指定生成正式版安装文件的配置 release { minifyEnabled false
//minifyEnabled指定是否对项目的代码进行混淆:true代表混淆 false表示不混淆
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//指定混淆时用的规则文件,第一个是android SDK目录下通用的规则文件
//第二个是为当前目录编写特有的混淆规则 } }}/**dependencies闭包 指定当前项目所有的依赖关系
AS有三种依赖关系:本地依赖、库依赖和远程依赖*/
dependencies {
//本地依赖 implementation fileTree(dir: 'libs', include: ['*.jar'])
//远程依赖 implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.android.support:design:26.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'}
阅读全文