Android Studio Gradle DSL method not found: 'android()' -- Error(17,0)
I went ahead and downloaded the project from the link you provided: http://javapapers.com/android/android-chat-bubble/
Since this is an old tutorial, you simply need to upgrade the software, gradle, the android build tools and plugin.
Make sure you have the latest Gradle and Android Studio:
- https://www.gradle.org/
- http://tools.android.com/tech-docs/new-build-system/version-compatibility
build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.2.1'
}
Then run gradle:
gradle installDebug
In your top level build.gradle
you seem to have the code
android {
compileSdkVersion 19
buildToolsVersion "19.1"
}
You can't have this code at the top level build.gradle
because the android build plugin isn't loaded just yet. You can define the compile version and build tools version in the app level build.gradle
.
For some unknown reason, Android Studio incorrectly adds the android() method in the top-level build.gradle file.
Just delete the method and it works for me.
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
}