简体   繁体   English

如何在新的 android studio 的 build.gradle 中为 firebase 添加谷歌服务类路径

[英]how can I add google services classpath for firebase in build.gradle of new android studio

My project's build.gradle code =我项目的 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
}

I am trying to add classpath 'com.google.gms:google-services:4.3.13' in my project's build.gradle file but am not getting any space to paste.我正在尝试在我的项目的 build.gradle 文件中添加classpath 'com.google.gms:google-services:4.3.13'但没有任何空间可以粘贴。 Even I have tried putting this before and after plugins =即使我尝试在插件之前和之后放置它=

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

Still I am having problem.我仍然有问题。 I also have tried to insert plugins inside dependencies but problem still occurs.我也尝试在依赖项中插入插件,但问题仍然存在。

Now, I need a solution.现在,我需要一个解决方案。

I am answering my problem just because to help out people who couldn't solve it.我回答我的问题只是为了帮助那些无法解决它的人。

The main thing here is, we have to add the dependencies before the "// Top level build....".这里的主要内容是,我们必须在“// Top level build....”之前添加依赖项。

I solved it sometimes before with a help.我有时在帮助下解决了它。

The code should be:代码应该是:

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
}

This is the main solve.这是主要的解决方法。 You can add more classpaths if you want.如果需要,您可以添加更多类路径。

 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!!!快乐的代码!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 build.gradle项目如何添加类路径依赖? - How to add classpath dependencies in build.gradle project? Android build.gradle失败Android工作室 - Android build.gradle fail Android studio 如何开发一个android build插件,为build.gradle添加一个依赖? - How to develop an android studio plugin that adds a dependency to the build.gradle? 在哪里可以找到build.gradle文件,以便在eclipse中添加android的支持库? - Where I can find build.gradle file in order to Add Support Libraries for android in eclipse? android studio中的build.gradle依赖项 - build.gradle dependencies in android studio 如何在Eclipse的现有Android应用上添加build.gradle - How to add build.gradle on existing Android app on Eclipse 错误:找不到com.google.gms:google-services:1.0。在android studio中的build.gradle中添加google服务插件时 - Error: Could not find com.google.gms:google-services:1.0. when adding google service plugin in build.gradle in android studio 新版Android Studio如何添加classpath - How to add classpath in new version of Android Studio 如何使用Gradle将类添加到classpath? - How can i add classes to classpath with gradle? 如何在运行时更改 build.gradle 中的 mainClassName? - How can I change mainClassName in build.gradle during runtime?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM