android 如何在最新版本的Gradle中添加项目级依赖项?

rqdpfwrv  于 2023-02-06  发布在  Android
关注(0)|答案(2)|浏览(118)

项目级别Gradle已更新,现在如下所示

plugins {
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

无论如何,我需要将此添加到我的项目级别Gradle:

dependencies {
    classpath 'com.google.gms:google-services:4.3.10'

  }

我读了这篇文章,仍然不明白如何实现这一点!

mnowg1ta

mnowg1ta1#

在项目级build.gradle文件中添加依赖项,如下所示

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.3.10'
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.1.3' apply false
    id 'com.android.library' version '7.1.3' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
b91juud3

b91juud32#

//Before adding
plugins {
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}

因此,要添加新版本的新依赖项,您可以直接添加它,如下所示:

//with classpath 'com.google.gms:google-services:4.3.10' to be added
//after adding
plugins {
    id 'com.android.application' version '7.1.2' apply false.
    id 'com.android.library' version '7.1.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
    id 'com.google.gms.google-services' version '4.3.10' apply false
}

相关问题