5

I've been experiencing build performances problems on my Mac since i started converting a project from java to kotlin.

I use gradle with Android Studio 3.0.1

The problem is that when i build/run/compile the source code I get a lot of warnings from the gradle console that are about code naming conventions, let me show you

I think that this is slowing down my build. I also tried to tweak a little bit my gradle configuration file and build script but nothing happened

org.gradle.daemon=true
org.gradle.jvmargs=-Xmx3072m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true

And also in my build.gradle top

tasks.whenTaskAdded { task ->
    if (task.name == "lint" || task.name == "lintVitalRelease") {
        task.enabled = false
    }
}

...

lintOptions {
    checkAllWarnings false
    checkReleaseBuilds false
    ignoreWarnings true       // false by default
    quiet true                // false by default
    tasks.lint.enabled = false
}

And I set the compiler parameters to -x lint, so I'm surprised by this error Anyone has the same problem?

4
  • See stackoverflow.com/questions/29046636/…
    – Renato
    Mar 16, 2018 at 22:32
  • 2
    Parameter "X" is never used. Could be renamed to _ Why don't you follow the prompts and rename those. The warnings will definitely go away.
    – Onik
    Mar 16, 2018 at 22:36
  • 1
    As the first warnings indicate, change 'compile' to 'implementation', etc, as that will dramatically improve build performance.
    – KTCO
    Mar 17, 2018 at 15:23
  • Why don't you follow the prompts : It's debetable whether or not it's good practice to hide the variable name for unused anonymous functions. I think it's weird that the Kotlin compiler makes that decision for us and make it a warning.
    – Nilzor
    Jun 22, 2021 at 20:27

2 Answers 2

9

The warnings that you see are reported by the Kotlin compiler, not by Android Lint, so lintOptions won't affect them.

Instead, if you want to suppress the warnings, you can configure a single Kotlin compilation task to suppress its warnings:

compileDebugKotlin {
    kotlinOptions.suppressWarnings = true
}

Or suppress the warnings from all Kotlin compilation tasks:

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions.suppressWarnings = true
}

Though in fact, these warnings should not affect the build performance in any noticeable way.

3
  • 1
    Is there any way to solve this without suppressing them?
    – c-an
    Apr 29, 2019 at 9:24
  • 1
    Yes, it does not directly affect build performance but when warnings are in 3 or 4 digits it shows down the system while printing them. So indirectly it affects the build system. But if u have that many warnings please try to solve them. But In that case suppressing warning will help build performance and reading app build trace Sep 2, 2021 at 7:22
  • even though I suppressed the warnings from all compilation tasks they are still shown! any idea why?
    – AouledIssa
    Oct 2, 2021 at 11:09
0

In newer versions of KGP, you can use:

android {
    // ...

   kotlinOptions {
       suppressWarnings = true
   }

  // ..
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.