Various version information in build.gradle of Android studio

Android studio uses gradle to build the project. Gradle is a very advanced project building tool. After we import the Android project, as long as the project synchronization is successful, the following folder will appear.

@H_ 404_ 4@

1. Apply plugin, which declares whether it is an Android application or a library module.

2. Android closure, which configures various attributes of project construction: (1) compilesdkversion is used to specify the variant SDK version of the project, (2) buildtoolsversion user specifies the version of the project construction tool. (3) Defaultconfig closure: default configuration, application package name, minimum SDK version, target SDK version, version number and version name. (4) Buildtypes closure: Specifies the configuration for generating installation files and whether to confuse the code; (5) Signingconfigs closure: signature information configuration; (6) Sourcesets closure: source file path configuration; (7) Lintoptions closure: Lint configuration;

3. Dependencies closure, which specifies all dependencies, local dependencies, library dependencies and remote dependencies of the current project;

4. Repositories closure, warehouse configuration.

//声明时Android程序
//com.android.application 表示这是一个应用程序模块,可直接运行
// com.android.library 标识这是一个库模块,是依附别的应用程序运行
apply plugin: 'com.android.application'

android {
	// 编译sdk的版本,也就是API Level,例如API-20、API-28等等。
    compileSdkVersion 28
	// build tools的版本,其中包括了打包工具aapt、dx等
	// 这个工具的目录位于你的sdk目录/build-tools/下    
    buildToolsVersion "28.0.2"
	// 认配置
    defaultConfig {
        applicationId "zj.dzh.qq" //应用程序的包名
        minSdkVersion 16  //最小sdk版本,如果设备小于这个版本或者大于maxSdkVersion将无法安装这个应用
        targetSdkVersion 28 //目标sdk版本,充分测试过的版本(建议版本)
        versionCode 1//版本号,第一版是1,之后每更新一次加1
        versionName "1.0"//版本名,显示用户看到的版本号

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"//Instrumentation单元测试
    }
// 指定生成安装文件的配置,常有两个子包:release,debug,注:直接运行的都是debug安装文件
    buildTypes {
    // release版本的配置,即生成正式版安装文件的配置
        release {
            minifyEnabled false// 是否对代码进行混淆,true表示混淆
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'//是否支持调试
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])// 本地依赖
    // 远程依赖,androidx.appcompat是域名部分,appcompat是组名称,1.0.2是版本号
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'// 声明测试用列库
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>