Android Studio lint reports "cannot infer argument types."

16,750

You can (very likely) safely ignore this warning. The IntelliJ (Android Studio) Groovy inspection is decent, but far from perfect. I have several advanced Gradle build scripts that are riddled with these and other inspection errors, although everything runs correctly. However, there is a chance you make a programming error and the inspection is technically correct, but you'll find that out once you attempt to execute your build script.

For this particular warning, you can turn it off on a by-line basis by using

//noinspection GroovyAssignabilityCheck

You can also turn it off entirely by going to File > Settings > Inspections and type Incompatible type assignments in the filter box and uncheck that inspection option. There you can also configure all the Groovy inspection options if you want to turn off others as well.

Share:
16,750
gonzobrains
Author by

gonzobrains

Check out my blog: http://www.gonzobrains.com

Updated on June 03, 2022

Comments

  • gonzobrains
    gonzobrains almost 2 years

    I have reviewed the Inspection report for my project that is provided by Android Studio after having executed the following command:

    Analyze->Inspect Code...
    

    The report indicates a problem with this code snippet in my gradle.build file:

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

    The specific problem is cannot infer argument types (at line 34). I have included a snapshot for clarity.

    Android Studio lint Inspection complaint

    One SO answer seems to suggest this is just a bogus warning. If that is the case, can I safely suppress this warning?

  • AxA
    AxA almost 9 years
    So, if this warning is correct, we will get an error about this while building, right?
  • Jeffrey Mixon
    Jeffrey Mixon almost 9 years
    @rpattabi "Building" is a somewhat ambiguous term. You will get an error at runtime when that particular statement is evaluated. If that happens when you run assembleDebug, for instance, then yes.
  • AxA
    AxA almost 9 years
    Got it. For the example shown here, the error will be while signing the apk. I just wanted to be sure signing wouldn't fail silently. I get the same lint warning and there is no error while signing. So I am assuming it is safe to ignore this warning in this case.