我如何添加谷歌服务classpath为firebase在build.gradle新的android工作室

bvk5enib  于 7个月前  发布在  Android
关注(0)|答案(2)|浏览(81)

我的项目的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.2.1' apply false
    id 'com.android.library' version '7.2.1' apply false
}

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

字符串
我试图在我的项目的build.gradle文件中添加classpath 'com.google.gms:google-services:4.3.13',但没有获得任何空间来粘贴。即使我尝试将此放在插件=之前和之后

dependencies {
  classpath 'com.google.gms:google-services:4.3.13'
}


我仍然有问题。我也试图插入插件内的依赖关系,但问题仍然发生。
我需要一个解决方案。

vaqhlq81

vaqhlq811#

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.3.13'
    }
}

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' version '7.2.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}

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

字符串
happy code!

hm2xizp9

hm2xizp92#

我回答我的问题只是为了帮助那些不能解决问题的人。
这里的主要内容是,我们必须在“// Top level build."之前添加依赖项。
我以前在别人的帮助下解决过。
代码应该是:

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

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

字符串
这是主要的解决方法。如果你愿意,你可以添加更多的类路径。

相关问题