我在 build.gradle(Project) 中找不到 buildscript

Hod*_*ori 22 android gradle firebase android-studio build.gradle

这就是我所知道的 build.gradle(Project) 。

buildscript {

    repositories {
        google()
        jcenter()
    }


    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0'
    }
}


allprojects {
    repositories {
        google()
        jcenter()
    }
}
Run Code Online (Sandbox Code Playgroud)

但我的项目的 build.gradle(Project) 就是这样。

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

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

我尝试将 Firebase 与 Android 链接,但 build.gradle(Project) 与我知道的文件不同。
我试图强行修改它,但它没有同步...
我如何访问顶级Gradle文件?

Pra*_*iya 38

对于 Android Studio Bumblebee,它们的build.gradle结构发生了变化。

您可以添加buildscript上面的内容plugins

buildscript {
  dependencies {
    // Add our classpath 
     classpath 'com.google.gms:google-services:4.3.10'
    // Add More 
 }
}
 plugins {
      id 'com.android.application' version '7.1.0' apply false
      id 'com.android.library' version '7.1.0' apply false
}

task clean(type: Delete) {
   delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

  • 在 Bumblebee 中还需要编写 buildscript{.. } allproject{...} 吗?settings.gradle 中的结构非常相似。 (3认同)