Android Plugin DSL Reference 参考文档 :
添加构建依赖项 参考文档 : https://developer.android.google.cn/studio/build/dependencies
org.gradle.api.Project 配置 ( build.gradle 根配置 ) 文档 : https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html
可以通过 configurations 配置 dependencies 依赖配置项 , Android 默认配置好了一批依赖配置项 , 如
这些配置也可以自定义 ;
configurations 配置 定义在了 org.gradle.api.Project 中 , 函数原型如下 :
void configurations(Closure configureClosure)
Configures the dependency configurations for this project.
This method executes the given closure against the ConfigurationContainer for this project.
The ConfigurationContainer is passed to the closure as the closure's delegate.
传入一个 Closure 闭包 作为参数 ;
配置示例 :
configurations {
myconfig {
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
myconfig 'androidx.appcompat:appcompat:1.4.1'
}
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有