androidgradlelintandroid-linttimber-android

Gradle clean fails because of lint & timber


Using Android Studio 1.5.1 on Windows 7, and gradle 2.8 or 2.10, I got the following error when trying to run a gradle clean (only when using Timber):

gradle clean
Incremental java compilation is an incubating feature.                           
WARNING [Project: :app] To shrink resources you must also enable ProGuard         
:clean                                                                               
:app:clean FAILED          

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:clean'.
> Unable to delete file: C:\blabla\app\build\intermediates\exploded-aar\com.jakewharton.timber\timber\4.1.0\jars\lint.jar

* Try:         
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Found this:
https://code.google.com/p/android/issues/detail?id=190812
and that:
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=5041014
But for Android Studio & gradle, we have no control on the compilation (so no control over the URLClassLoader calls).


Solution

  • Disable all of Timber's lint checks, in build.gradle:

    android {
    
      lintOptions {
        disable 'LogNotTimber', 'StringFormatInTimber', 'ThrowableNotAtBeginning', 'BinaryOperationInTimber', 'TimberArgCount', 'TimberArgTypes', 'TimberTagLength'
      }
    }
    

    I also suggest submitting a PR that fixes the issue so you can turn these checks back on. You don't want to suppress these indefinitely.