Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle dagger lint: ignore by package

I've created an Android project using Gradle. I've added a Dagger library:

dependencies {
    compile 'com.squareup.dagger:dagger-compiler:1.2.1'
    compile 'com.squareup.dagger:dagger:1.2.1'
}

After trying to compile the project I get a build failure due to lint exceptions:

InvalidPackage: Package not included in Android

../../../../../../.gradle/caches/modules-2/files-2.1/com.squareup.dagger/dagger-compiler/1.2.1/c8bf6c2fda9b27f4d44a2aa4280df525a1408771/dagger-compiler-1.2.1.jar: Invalid package reference in library; not included in Android: javax.annotation.processing. Referenced from dagger.internal.codegen.GraphAnalysisErrorHandler.

../../../../../../.gradle/caches/modules-2/files-2.1/com.squareup.dagger/dagger-compiler/1.2.1/c8bf6c2fda9b27f4d44a2aa4280df525a1408771/dagger-compiler-1.2.1.jar: Invalid package reference in library; not included in Android: javax.lang.model.type. Referenced from dagger.internal.codegen.GeneratorKeys.

../../../../../../.gradle/caches/modules-2/files-2.1/com.squareup.dagger/dagger-compiler/1.2.1/c8bf6c2fda9b27f4d44a2aa4280df525a1408771/dagger-compiler-1.2.1.jar: Invalid package reference in library; not included in Android: javax.lang.model.util. Referenced from dagger.internal.codegen.GraphAnalysisErrorHandler.

../../../../../../.gradle/caches/modules-2/files-2.1/com.squareup/javawriter/2.3.0/4b290e394ea3109be5c0b7f08ff75de089125122/javawriter-2.3.0.jar: Invalid package reference in library; not included in Android: javax.lang.model.element. Referenced from com.squareup.javawriter.JavaWriter.

So, I have to either fix or make lint ignore Dagger packages. I've setup lint.xml but I can't figure out a way to ignore:

 <issue id="InvalidPackage">
  <ignore ...INSERT DECLARATION TO IGNORE DAGGER PACKAGE... />
 </issue>

Thanks.

like image 679
midnight Avatar asked Feb 17 '14 10:02

midnight


2 Answers

Found the answer here: https://android.googlesource.com/platform/tools/base/+/e6a5b9c7c1bca4da402de442315b5ff1ada819c7

adding in build.gradle in android section, lintOptions solved the issue for me:

android {
...

   lintOptions {
       disable 'InvalidPackage'
   }
}

adding the same ignore statement in lint.xml did not worked for me.

like image 103
Mihaela Romanca Avatar answered Oct 08 '22 01:10

Mihaela Romanca


FYI, as of version 0.10.1 of the Android Gradle plugin this will no longer be necessary; lint will automatically ignore these issues found within Dagger: https://android-review.googlesource.com/#/c/93140/

like image 23
Tor Norbye Avatar answered Oct 07 '22 23:10

Tor Norbye