0

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 compileSdkVersion to 22 and also changed minSdkVersion and targetSdkVersion 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?

Opal
  • 81,889
  • 28
  • 189
  • 210
DSlomer64
  • 4,234
  • 4
  • 53
  • 88

3 Answers3

2

Those warnings can be ignored, I have them throughout my projects as well.

I have a top level gradle.build file and reference some parameters from it in lower level gradle.build files. I think that is where the error comes from in my case. Gradle can't tell what argument type it is.

Nick H
  • 8,897
  • 9
  • 41
  • 64
  • 1
    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 issues. For example using the appcompat v22 you would have errors using api 19. – Gabriele Mariotti Jan 07 '16 at 13:18
  • 1
    You are correct, that particular problem should not be ignored. But the specific error message concerning incompatible types can be safely ignored, depending on the situation. – Nick H Jan 07 '16 at 13:21
2

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

Community
  • 1
  • 1
Viral Patel
  • 32,418
  • 18
  • 82
  • 110
  • 1
    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 issues. For example using the appcompat v22 you would have errors using api 19. – Gabriele Mariotti Jan 07 '16 at 13:18
  • 1
    agree, i was focusing mostly on the `cannot be applied to groovy.lang.Closure` messages. Skipped that one in the rush. Will update my answer. – Viral Patel Jan 07 '16 at 13:21
0

As it turns out, I guess because of upgrade, the folder previously containing Gradle wasn't found. I changed it to C:\Program Files\Android\Android Studio\gradle\gradle-2.8 and all was well except for two warnings, both suggesting using latest version of Android, so I made the suggested changes (new Gradle.build file below) and have no warnings:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.dslomer64.wordyhelperton"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 16
        versionName "3.022"
    }

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

dependencies {
    compile 'com.android.support:support-v4:23.1.1'
}

I also changed Build, Execution, Deployment to have Gradle use the default Gradle wrapper instead of the local specific folder (2.8 as reported above) as discussed here.

Community
  • 1
  • 1
DSlomer64
  • 4,234
  • 4
  • 53
  • 88