【问题标题】:Android Studio. Error:(19,0)安卓工作室。错误:(19,0)
【发布时间】:2016-03-11 22:24:18
【问题描述】:

更新Android Studio、SDK和工具后出现问题:

错误:(19, 0) Gradle DSL 方法未找到:'android()'

请帮忙解决:

顶部 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:1.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}

android {
    compileSdkVersion 16
   // buildToolsVersion '22.0.1' //23.02.2
}
dependencies {
}

另一个build.gradle(Module:app)文件:

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 16
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.mateuyabar.android.pillownfc"
        minSdkVersion 10
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.0'
}

这是 Gradle Sync 的错误消息:

错误:(19, 0) Gradle DSL 方法未找到:'android()'

可能的原因:

项目“pillowNFC-master”可能正在使用不包含该方法的 Gradle 版本。 -打开 Gradle 包装文件

构建文件可能缺少 Gradle 插件。 - 应用 Gradle 插件

事件日志:

11:20:46 Gradle 同步开始

11:20:48 Gradle 同步失败:未找到 Gradle DSL 方法:'android()' 查看 IDE 日志了解更多详情(帮助 | 显示日志)

我知道,之前有人问过这个问题,但是我在其他讨论中没有找到解决方案 =(

如果有人能帮忙就好了,我是编程新手。

【问题讨论】:

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


    【解决方案1】:

    您使用了错误的build.gradle 文件

    在您的顶级文件中您不能使用android 块。
    还要检查这个post

    只需从第一个 build.gradle 中删除这部分

    android {
        compileSdkVersion 16
       // buildToolsVersion '22.0.1' //23.02.2
    }
    dependencies {
    }
    

    还要注意。
    由于您使用的是 appcompat v23,您您必须使用 API 23 进行编译

    在您的module/build.gradle 中将compileSdkVersion 更改为23

     compileSdkVersion 23
    

    【讨论】:

    • 非常感谢,它有帮助。我忘了,最新的版本是 23。
    • 如果它解决了您的问题,请标记答案。它可以帮助其他用户。
    猜你喜欢
    • 1970-01-01
    • 2013-07-08
    • 2017-04-17
    • 2014-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多