gpt4 book ai didi

android - Gradle DSL 方法未找到 : 'compile()'

转载 作者:IT老高 更新时间:2023-10-28 13:12:01 31 4
gpt4 key购买 nike

我遇到了这个 gradle 错误。

Error:(9, 0) Gradle DSL method not found: 'compile()'

我曾尝试引用类似的问题,但没有奏效。

Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'.

Getting Error "Gradle DSL method not found: 'compile()'" when Syncing Build.Gradle

Unsupported Gradle DSL method found: 'compile()'!

我的 build.gradle 代码在这里

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services:6.5.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

build.gradle(Module.app)

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.1"

defaultConfig {
applicationId "com.example.simplemaker.pushtest"
minSdkVersion 9
targetSdkVersion 21
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:21.0.3'
}

我的代码有什么问题?

最佳答案

正如您项目的 build.gradle 文件的注释所示:

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

删除该 gradle 文件中的 2 个编译语句:

compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services:6.5.+'

然后让你的其他(模块的)build.gradle 依赖项看起来像这样:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.+'
}

关于android - Gradle DSL 方法未找到 : 'compile()' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27617687/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com