You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

build.gradle编译报错:buildscript块需置于plugins块之前

问题解决:build.gradle编译报错(buildscript块需置于plugins块之前)

报错原因

Gradle语法规则明确要求:所有buildscript {}块必须出现在脚本中任意plugins {}块之前,你的代码里plugins块写在了buildscript块前面,违反了该规则,导致编译失败。

修正后的代码

将buildscript块移至plugins块上方即可,修正后的完整代码如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
    }
}

plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

内容的提问来源于stack exchange,提问作者Mauro Stancato

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 08:03:02