zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

【Android Gradle 插件】Module 目录下 build.gradle 配置文件 ( android 闭包块配置 | AppExtension 扩展类型参考文档 )

2023-09-14 09:07:28 时间

Android Plugin DSL Reference 参考文档 : https://google.github.io/android-gradle-dsl/2.3/





一、Module 目录下 build.gradle 配置文件



1、android 闭包块配置


build.gradle 中配置了 android 闭包块 , 但是无法跳转到 android 方法位置 , 该方法不是 Project 中的方法 , 而是 com.android.application 插件中提供的方法 ;

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.aop"
        minSdkVersion 18
        targetSdkVersion 30
        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
    }
}

android 方法原型 :

com.android.build.gradle.internal.dsl.BaseAppModuleExtension android (groovy.lang.Closure configuration)

在这里插入图片描述


2、AppExtension 扩展类型参考文档


该 android 方法定义在 AppExtension 扩展类型中 , 下面简单介绍该扩展类型 ;

android 方法中的配置参考 https://google.github.io/android-gradle-dsl/2.3/com.android.build.gradle.AppExtension.html 文档 ;

在这里插入图片描述