【问题标题】:Gradle suddenly will not build. Gradle DSL method not found: 'android()'Gradle 突然无法构建。找不到 Gradle DSL 方法:'android()'
【发布时间】:2015-12-28 20:29:33
【问题描述】:

我的 Gradle 突然决定不再构建我的项目,我不知道。我怀疑它是因为它在 Dropbox 上,但在我研究它的那个月里这不是问题。我没有在我的构建文件中编辑任何内容。我将 java JDK 更新为最新,并确保项目指向它。 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.2.3'

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

android {
    compileSdkVersion 22
}
dependencies {
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.nan.spymap"
        minSdkVersion 21
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories { mavenCentral() }

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile fileTree(include: 'ParseFacebookUtilsV4-*.jar', dir: 'libs')

    compile 'com.facebook.android:facebook-android-sdk:4.6.0'
    compile 'com.google.android.gms:play-services:7.8.0'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.android.support:appcompat-v7:22.1.0'
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    compile 'com.android.support:design:22.2.0'

}

【问题讨论】:

  • 没有人可以帮忙吗? :(

标签: java android android-gradle-plugin


【解决方案1】:

项目(顶层)的build.gradle 文件不能包含android 根标签。尝试删除它。

【讨论】:

  • 嗨,我是 gradle 的新手以及它是如何构建的,你能更具体地了解一下具体是哪一行吗?
  • 我是关于 android { compileSdkVersion 22 } 在你的顶级文件中
  • 如果我删除 android { compileSdkVersion 22 }
  • 我收到另一个错误.. 任务“未在根项目中找到”
  • 出现此错误,您可以检查stackoverflow.com/questions/25172006/…。当我在那里阅读时,您应该尝试清理项目并确保使用默认的 gradle 包装器
猜你喜欢
  • 2015-01-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-16
相关资源
最近更新 更多