DSlomer64 DSlomer64 - 3 months ago 8x
Android Question

build.gradle file errors and warnings after upgrade to Android Studio 1.5.1

Here's my build.gradle file. After updgrading to AS 1.5.1 and attempting to compile/sync, I got error on last line, but program executes fine:

apply plugin: 'com.android.application'

android {
compileSdkVersion 19
buildToolsVersion "22.0.1"

defaultConfig {
applicationId "com.dslomer64.wordyhelperton"
minSdkVersion 19
targetSdkVersion 19
versionCode 16
versionName "3.02"

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'

dependencies {
compile 'com.android.support:support-v4:22.2.1'

The error is on the last line above (
compile 'com.android....-v4:22.2.1
It says:

This support library should not use a different version (22) than the
compileSdkVersion (19).

So I changed
to 22 and also changed
to 22 since the first change alone still gave warnings, but NO ERRORS.

The warnings are on every line from 'defaultConfig' down.

The warning is:

defaultConfig cannot be applied to groovy.lang.Closure ... assignment with incompatible types

What should I do? App compiles and runs fine. Is ignoring these warnings are OK?


Yes, messages like ...cannot be applied to groovy.lang.Closure can be ignored, but if you want to fix them here are a few answers that will help you:

Quick fix - just a small change in settings.

Proper and lengthy fix - creating a top level build.gradle.

Missed this earlier but thanks to Gabriele for pointing it out in the comment below:

The warning about the api to be used to compile the project, should not be ignored. You have to compile with the same version of the maior release (in this case 22) otherwise you can have issue. For example using the appcompat v22 you would have errors using api 19