【问题标题】:Gradle project sync failed. During the 1st run [closed]Gradle 项目同步失败。在第一次运行期间[关闭]
【发布时间】:2018-08-04 23:16:52
【问题描述】:

我第一次尝试安装 Android Studios,我在 gradle 同步时看到以下错误。

Android 版本:ICS

PC:Windows

这是我的 build.gradle(Module: app)

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 26
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
}

错误

错误:(1, 0) 找不到参数的方法 android() [build_5pnbu8h0dy4utgbvgbaqkp5m1$_run_closure1@1219d79f] 在项目上 ':app' 类型为 org.gradle.api.Project。

【问题讨论】:

  • 发布您的顶级 build.gradle 文件

标签: android android-studio sdk android-gradle-plugin build.gradle


【解决方案1】:

在您的app/build.gradle 文件中,您必须添加android 插件。

apply plugin: 'com.android.application'

android { ... }

【讨论】:

  • 在 Gradle 同步 12 错误和 2 警告中出现错误生成文件夹下的文件且不应编辑
  • 您必须编辑 app/build.gradle 而不是 build 文件夹中的文件
猜你喜欢
  • 2015-06-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-03
  • 2014-04-04
相关资源
最近更新 更多