在学习过程中,对于build.gradle文件的一些配置解释
/*
插件。表明这是一个应用程序模块。可以直接运行。
com.android.library 表示一个库模块,需要依赖别的应用程序来运行。
*/
plugins {
id 'com.android.application'
}
android {
//编译指定的SDK版本号。
compileSdk 32
defaultConfig {
//指定该模块的应用编号,也是APP的包名。自动生成,无需修改
applicationId "com.example.weather_app"
//指定APP适合运行的最小SDK版本号
minSdk 14
//指定目标设备的SDK版本号,即最优版本号
targetSdk 32
//指定APP的应用版本号
versionCode 1
//指定APP的应用版本名称
versionName "1.0"
//表明要使用AndroidJUnitRunner进行单元测试。
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
//指定是否开启代码混淆功能,true表示开启,false表示无需
minifyEnabled false
//指定代码混淆规则文件的文件名
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
//指定APP的版本依赖信息:本地依赖、库依赖及远程依赖。
dependencies {
//指定引用jar包的路径
//远程依赖
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
// 声明测试用列库,只在单元测试代码及打包测试apk时有效。
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
更详细的build.gradlej解释。
https://blog.youkuaiyun.com/chaozhung_no_l/article/details/107542628