android开发中build.gradle文件详解
16lz
2021-01-23
app目录下的build.gradle文件
apply plugin: 'com.android.application'//表示这是一个应用 com.android.library表示这是一个库文件android { compileSdkVersion 29 //sdk版本 buildToolsVersion "29.0.0" //构建工具版本 defaultConfig { applicationId "com.example.newtest" //包名 minSdkVersion 21 //最低兼容的Android系统版本 targetSdkVersion 29 //为你的应用程序启用一些该版本的新新功能和特性, versionCode 1 //版本号 versionName "1.0" //版本名 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ndk { //设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so) abiFilters "armeabi","armeabi-v7a","arm64-v8a", "x86","x86_64" } } //buildTyoes闭包用于指定生成安装文件的相关配置 buildTypes { //relsease闭包指定生成安装文件的相关配置 //debug用于指定生成测试版安装文件的配置 release { //minifyEnable用于指定是否对项目的代码进行混淆,true表示混淆,false表示不 minifyEnabled false //proguard-android-optimize.txt 表示所有项目通用的混淆规则,proguard-rules.pro表示特有的混淆规则,至于当前项目的根目录下 //此处为空 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } //注:通过android studio直接运行项目生成的都是测试版安装文件 }}//dependencise 闭包可以指定当前项目所有的依赖关系dependencies { //本地依赖声明 implementation fileTree(dir: 'libs', include: ['*.jar']) //远程依赖,自动在jcengter库中下载这个依赖,implementation用于项目中文件 implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' //testImplementation 声明测试用例库 // testImplementation用于test下文件 testImplementation 'junit:junit:4.12' // androidTestImplementation用于androidtest下文件 androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation 'com.amap.api:3dmap:5.0.0' implementation 'com.amap.api:location:3.3.0' implementation 'com.amap.api:search:5.0.0'}
最外层目录下的build文件
//管理全局项目配置,通常不需要修改buildscript { repositories { google() jcenter() //jcenter是一个代码托管仓库 } dependencies { //声明一个Gradle插件 classpath 'com.android.tools.build:gradle:3.4.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}allprojects { repositories { google() jcenter() }}task clean(type: Delete) { delete rootProject.buildDir}
更多相关文章
- Android在配置文件中配置Button再不同情况下的的背景
- Android通过SOCKET下载文件的方法
- android历史版本
- 00_JNI头文件
- Android 之 使用Pull 解析xml文件
- android关于蓝牙不能传送APK文件
- Android布局文件-错误