Make sure you have a settings.gradle
file in your project. Adding that solved the problem of Error:Gradle DSL method not found: 'minSdkVersion()'
for me.
Deleting .gradle in my project folder did the job for me.
In almost all cases, your dependencies should be put into the individual module's build.gradle files rather than at the top most level build.gradle file. In your case, that means the dependency should be added to the app
module's build.gradle file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:support-v4:18.0.+"
}
And you should remove the entire allprojects
part of the top level build.gradle.
I have the same issue, and the bug is my build.gradle of application level has dependencies of my submodules. Means
dependencies {
compile project(':library')
compile project(':MPChartLib')
}
I have just remove the two line inside the dependencies braces and it is able to start syncing.
I have found that when I add an applicationSuffix
or versionNameSuffix
through the IDE menu (Build > Edit Build Types), it changes the dependencies section of my app build.gradle from this:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
testCompile 'org.json:json:20140107'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:support-vector-drawable:${supportLibVersion}" // VectorDrawableCompat
compile "com.android.support:animated-vector-drawable:${supportLibVersion}" // AnimatedVectorDrawableCompat
}
to this:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
testCompile 'org.json:json:20140107'
compile "com.android.support:appcompat-v7:${supportLibVersion}" compile "com.android.support:design:${supportLibVersion}" compile "com.android.support:support-vector-drawable:${supportLibVersion}"
// VectorDrawableCompat
compile "com.android.support:animated-vector-drawable:${supportLibVersion}"
// AnimatedVectorDrawableCompat
}
I don't know why, but it combines the first three "compile" lines into one line, and moves the two comments (to the next line in each case).
I solved the problem by editing the app build.gradle and putting each "compile" statement onto its own line.
You have 2 different build.gradle
(sometimes more depending on you)
Only one of them is your app's gradle, then the other one is project's gradle.
If you put your dependencies project's gradle you can get error : Gradle DSL method not found: 'compile()'
Put your dependencies in app's build.gradle
then it will work.