I updated a plugin of Android studio. Now when I try to open an existing project I got an error.
Error:(10, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'TuteSample' may be using a version of Gradle that does not contain the method.
The build file may be missing a Gradle plugin.
This is my 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.2.3'
compile "com.android.support:appcompat-v7:21.0.+"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files }
}allprojects {
repositories {
jcenter()
}
}
Make sure about it that your dependencies should be put into the individual module's build.gradle files instead of at the top most level build.gradle file. Placed your dependencies as:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:21.0.+"
}
Add compile "com.android.support:appcompat-v7:21.0.+"
into Module build.gradle would be:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "your_package_name"
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:21.0.+"
}
Top level build.gradle would be:
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()
}
}
Copy the compile 'com.android.support:appcompat-v7:21.0.+'
from project build.gradle into module bulid.gradle . like this file
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "xxxx"
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:21.0.+'
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.