I\'m getting this warning in my project gradle file:
Warning:(16, 5) \'buildTypes\' cannot be applied to \'(groovy.lang.Closure< com.android.build.
Changing the buildToolsVersion
from
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
..
}
to
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
..
}
worked for me.
The easiest way to fix this Gradle issues is recreating the project to let Android Studio reconfigure Gradle.
Simply select "Open an existing Android Studio project" and pick your project folder.
More details here.
I managed to solve my issue by simply doing this: Click "File" then select "Invalidate Caches/ Restart
The issue at hand is that your Android Studio settings that you probably imported at upgrade, was still pointing to gradle-2.4 or some other versions than Android Studio 1.5 expects.
To solve this problem, you should open up Settings and go to Build, Execution, Deployment > Build Tools > Gradle and change your local gradle distribution's home path or select the default gradle wrapper.
Apply and re-sync your project.
In my case my buildTypes
section was above my productFlavors
section. Interchanging their positions got rid of the warning:
BEFORE:
buildTypes {
debug {
minifyEnabled false
shrinkResources false
...//etc
}
}
productFlavors {
demo {
...//etc
}
}
AFTER:
productFlavors {
demo {
...//etc
}
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
...//etc
}
}
I am using Android Studio 2.1.2 with the following config at the top of my android
section:
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.xyz.abc"
minSdkVersion 14
targetSdkVersion 24
//..etc
I had the same problem. I started a new project and it worked, so I just copied the build.gradle file. In my case the only difference was the lack of the compileOptions section. I removed it from my project, synced gradle, re-inserted the compileOptions section and then synced gradle again.