[英]Where to put Android Gradle Plugin version in the new Android Studio (Bumblebee and above) Gradle setup?
When you are creating new Android project with the latest version of Android Studio it will now give you a project level build.gradle
that only contains plugins block当您使用最新版本的 Android Studio 创建新的 Android 项目时,它现在将为您提供仅包含插件块的项目级别build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
My question is how to specify now the version of AGP with this setup?我的问题是现在如何使用此设置指定 AGP 的版本? Before it looks like this在它看起来像这样之前
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
// This block encapsulates custom properties and makes them available to all modules in the project.
ext {
kotlin_version = '1.6.20-M1'
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.0-alpha03'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
I also wonder how would you add classpath on some plugins that still requires it like我也想知道你将如何在一些仍然需要它的插件上添加类路径,比如
classpath 'com.google.gms:google-services:4.3.10'
What I also do not understand is what does com.android.library
plugin do and why is it in app module?我也不明白com.android.library
插件是做什么的,为什么它在应用程序模块中?
Another thing to ask is with this new setup you have two plugins block, one in app level and one in project level.要问的另一件事是,通过这个新设置,您有两个插件块,一个在应用程序级别,一个在项目级别。 Is this really necessary?这真的有必要吗? What is the point of that?那有什么意义呢? Thanks谢谢
This new Gradle setup is called plugins DSL
, it is the new way to add Gradle plugin dependency without needing to add its classpath
.这个新的 Gradle 设置称为plugins DSL
,它是添加 Gradle 插件依赖项而无需添加其classpath
的新方法。 While the old legacy way requires you to include the dependency's classpath inside the buildscript
block.虽然旧的遗留方式要求您在buildscript
块中包含依赖项的类路径。
Note that some of the plugins like com.google.gms:google-services:${version}
still not support the new plugin DSL and you are required to add buildscript
using the legacy approach.请注意, com.google.gms:google-services:${version}
等一些插件仍然不支持新插件 DSL,您需要使用旧方法添加buildscript
。
buildscript {
dependencies {
classpath "com.google.dagger:hilt-android-gradle-plugin:2.38.1"
}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.