天天看點

【Android Gradle 插件】Module 目錄下 build.gradle 配置檔案 ( android 閉包塊配置 | AppExtension 擴充類型參考文檔 )

文章目錄

  • ​​一、Module 目錄下 build.gradle 配置檔案​​
  • ​​1、android 閉包塊配置​​
  • ​​2、AppExtension 擴充類型參考文檔​​

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)      
【Android Gradle 插件】Module 目錄下 build.gradle 配置檔案 ( android 閉包塊配置 | AppExtension 擴充類型參考文檔 )

2、AppExtension 擴充類型參考文檔

該 android 方法定義在 AppExtension 擴充類型中 , 下面簡單介紹該擴充類型 ;

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