首页 > 解决方案 > 在我的代码中找不到导致 R 错误的方法 android

问题描述

错误:(15, 0) 在根项目“ud839_Miwok-Starter-code”上找不到参数 [build_41ptob9czd5ucux9ngzednsn4$_run_closure1@100eeb5] 的方法 android()。打开文件

我还尝试在仍然连接互联网的情况下重建 gradle,

下面是我的 build.gradle 代码

// Top-level build file where you can add configuration options common to all sub-projects/modules.

 buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

android {
buildToolsVersion "28.0.3"

}

allprojects {
repositories {
    jcenter()
}
}

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

标签: androidandroid-studio

解决方案


您的build.gradle文件属于项目级别。请将以下行移至模块 build.gradle文件。

android {
  buildToolsVersion "28.0.3"
}

详细参考在这里。


推荐阅读