简体   繁体   English

Android Gradle 插件版本在新的 Android Studio (大黄蜂及以上)Z7B5CC4FB56E171DC75Z0FBB361

[英]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.

相关问题 更新到大黄蜂 android 工作室版本时出现错误 gradle - error gradle when update to bumblebee android studio version Android Studio Bumblebee 无法读取 Gradle 中的文件路径 - Android Studio Bumblebee is not able to read FilePaths in Gradle Gradle 7.1:在 Android Studio Bumblebee 中开发自定义 gradle 插件时出现问题 - Gradle 7.1 : Problems with developing custom gradle plugins in Android Studio Bumblebee Gradle插件版本与Real Gradle版本Android Studio冲突 - Gradle plugin version conflicting with realm gradle version Android Studio Android Studio版本与使用的Gradle插件不兼容 - Version of Android Studio is incompatible with the Gradle Plugin used 无法在新的 Gradle 结构 Android Studio Bumblebee 上集成 OneSignal Android SDK - Unable to Integrate OneSignal Android SDK on new Gradle Structure Android Studio Bumblebee 到底在Android Studio中将gradle依赖放在哪里? - Where exactly to put gradle dependecies in Android Studio? 将Android Studio Gradle插件更新到最新版本 - Update Android Studio Gradle plugin to last version Android Studio不支持的Gradle插件版本 - Android Studio Unsupported Version of Gradle Plugin Android Studio,gradle插件和gradle版本信息丢失 - Android Studio, gradle plugin and gradle version information missing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM