- 项目级别的build.gradle指定了当前项目的总体编译规则
- 模块级别build.gradle需要进行详细介绍
plugins {
id 'com.android.application'
}
android {
//指定编译用的SDK版本号
compileSdk 34
defaultConfig {
// 指定该模块的应用编号,也就是APP的包名,也就是应用的身份证号码
applicationId "com.example.myapplication"
// APP最小适合运行的SDK版本号
minSdk 28
// 指定目标设备的SDK版本号,表示APP最希望在哪里运行
targetSdk 34
// APP的应用版本号(唯一表示)
versionCode 1
// 版本名称
versionName "1.0"
// 单元测试类
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
// 指定混淆规则文件
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
// 做好兼容性的解决方案,APP编译的依赖信息
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}