详解build.gradle文件

在学习过程中,对于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.csdn.net/chaozhung_no_l/article/details/107542628

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值