英文:
all buildscript {} blocks must appear before any plugins {} blocks in the script :8 ~ Android Studio
问题
Here is the translated content:
我正在使用Java创建一个应用程序,并将数据库连接到Firebase。我在构建文件中遇到了这个错误。请帮助我解决这个错误。
我无法理解错误消息,请解释如何解决它。
错误 👇👇👇
构建文件 'D:\MyWeb\build.gradle' 第 7 行
无法编译构建文件 'D:\MyWeb\build.gradle'。
> 启动失败:
构建文件 'D:\MyWeb\build.gradle':7:所有 buildscript {} 块必须出现在脚本中任何 plugins {} 块之前
build.grable(我的Web)
// 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。
plugins {
id 'com.android.application' version '8.0.2' apply false
id 'com.android.library' version '8.0.2' apply false
}
buildscript {
repositories {
google() // Google 的 Maven 存储库
mavenCentral() // Maven 中央存储库
}
dependencies {// 添加 Google 服务 Gradle 插件的依赖项
classpath 'com.google.gms:google-services:4.3.15'
}
}
allprojects {
repositories {// 确保您拥有以下两个存储库
google() // Google 的 Maven 存储库
mavenCentral() // Maven 中央存储库
}
}
build.gradle (:app)
// 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。
plugins {
id 'com.android.application' version '8.0.2' apply false
id 'com.android.library' version '8.0.2' apply false
}
buildscript {
repositories {
google() // Google 的 Maven 存储库
mavenCentral() // Maven 中央存储库
}
dependencies {// 添加 Google 服务 Gradle 插件的依赖项
classpath 'com.google.gms:google-services:4.3.15'
}
}
allprojects {
repositories {// 确保您拥有以下两个存储库
google() // Google 的 Maven 存储库
mavenCentral() // Maven 中央存储库
}
}
我正在尝试将我的Android Studio项目连接到Firebase,但我在build.gradle中遇到了错误。不确定如何修复它。
英文:
I am creating an application using Java and connecting the database to Firebase. I am getting this error in the build file. Please help me to solve this error.
I can't understand the error message please explain me to solve it.
Error 👇👇👇
Build file 'D:\MyWeb\build.gradle' line: 7
Could not compile build file 'D:\MyWeb\build.gradle'.
> startup failed:
build file 'D:\MyWeb\build.gradle': 7: all buildscript {} blocks must appear before any plugins {} blocks in the script
build.grable(My Web)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.0.2' apply false
id 'com.android.library' version '8.0.2' apply false
}
buildscript {
repositories {
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.15'
}
}
allprojects {
repositories {// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}
build.gradle (:app)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.0.2' apply false
id 'com.android.library' version '8.0.2' apply false
}
buildscript {
repositories {
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.15'
}
}
allprojects {
repositories {// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}
I'm trying to connect my Android Studio project to Firebase, but I get an error with the build.gradle. Not sure how to fix it.
答案1
得分: 2
只需删除buildscript{}块,并将其添加到plugins{}块的顶部,像这样:
// 顶级构建文件,在此处可以添加所有子项目/模块共用的配置选项。
buildscript {
repositories {
google() // Google的Maven仓库
mavenCentral() // Maven中央仓库
}
dependencies {// 添加Google服务Gradle插件的依赖项
classpath 'com.google.gms:google-services:4.3.15'
}
}
plugins {
id 'com.android.application' version '8.0.2' apply false
id 'com.android.library' version '8.0.2' apply false
}
allprojects {
repositories {// 确保您有以下两个仓库
google() // Google的Maven仓库
mavenCentral() // Maven中央仓库
}
}
永远记住buildscript{}块应位于plugins{}块的顶部。
英文:
Simply remove the buildscript{} block and add it on top of plugins{} block, Like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.15'
}
}
plugins {
id 'com.android.application' version '8.0.2' apply false
id 'com.android.library' version '8.0.2' apply false
}
allprojects {
repositories {// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}
Always remember that buildscript{} block should be on top of plugins{} block.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论