timber: AGP 7.0.0-alpha13: lint task fails

When running the lint task with AGP 7.0.0-alpha13 it will fail with the following error:

The lint detector
timber.lint.WrongTimberUsageDetector
called context.getMainProject() during module analysis.

This does not work correctly when running in cli.

In particular, there may be false positives or false negatives because
the lint check may be using the minSdkVersion or manifest information
from the library instead of any consuming app module.

Contact the vendor of the lint issue to get it fixed/updated (if
known, listed below), and in the meantime you can try to work around
this by disabling the following issues:

"LogNotTimber","StringFormatInTimber","ThrowableNotAtBeginning","BinaryOperationInTimber","TimberArgCount","TimberArgTypes","TimberTagLength","TimberExceptionLogging"

Issue Vendors:
Identifier: timber-4.7.1

Call stack: Context.getMainProject(Context.kt:117)
←WrongTimberUsageDetector.visitMethod(WrongTimberUsageDetector.java:80)
←Detector.visitMethodCall(Detector.kt:551)
←UElementVisitor$DelegatingPsiVisitor.visitMethodCallExpression(UElementVisitor.kt:1095)
←UElementVisitor$DelegatingPsiVisitor.visitCallExpression(UElementVisitor.kt:1075)
←KotlinUFunctionCallExpression.accept(KotlinUFunctionCallExpression.kt:186)
←UQualifiedReferenceExpression$DefaultImpls.accept(UQualifiedReferenceExpression.kt:34)
←KotlinUQualifiedReferenceExpression.accept(KotlinUQualifiedReferenceExpression.kt:29)
←UQualifiedReferenceExpression$DefaultImpls.accept(UQualifiedReferenceExpression.kt:33)
←KotlinUQualifiedReferenceExpression.accept(KotlinUQualifiedReferenceExpression.kt:29)
←ImplementationUtilsKt.acceptList(implementationUtils.kt:23)
←UBlockExpression$DefaultImpls.accept(UBlockExpression.kt:21)
←KotlinUBlockExpression.accept(KotlinUBlockExpression.kt:24)
←ULambdaExpression$DefaultImpls.accept(ULambdaExpression.kt:33)
←KotlinULambdaExpression.accept(KotlinULambdaExpression.kt:29)
←ImplementationUtilsKt.acceptList(implementationUtils.kt:23)
←KotlinUFunctionCallExpression.accept(KotlinUFunctionCallExpression.kt:190)
←UQualifiedReferenceExpression$DefaultImpls.accept(UQualifiedReferenceExpression.kt:33)
←KotlinUQualifiedReferenceExpression.accept(KotlinUQualifiedReferenceExpression.kt:29)
←ImplementationUtilsKt.acceptList(implementationUtils.kt:23)

Everything works fine when using AGP 7.0.0-alpha12. Disabling the issues obviously works as a temporary workaround.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 15
  • Comments: 20 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Any update on this issue?

I have this issue with AGP 7.0.0.

    classpath "com.android.tools.build:gradle:7.0.0"
    implementation 'com.jakewharton.timber:timber:4.7.1'

I’m still experiencing this issue with:

// Android Gradle Plugin 7.0.0-beta04:
classpath 'com.android.tools.build:gradle:7.0.0-beta04'

// Timber 4.7.1:
implementation 'com.jakewharton.timber:timber:4.7.1'

There are a few PRs waiting to be merged that should fix this.

I am seeing this error with both AGP alpha-13 and alpha-14. It was fine with alpha-12. Can work around it with android.enableParallelLint=false in gradle.properties.

Upgrading our AGP to alpha-14 seems to have solved this issue for us

Getting https://github.com/JakeWharton/timber/pull/410 merged would probably be a step in the right direction (I suppose I should clean up some of the deploy stuff 🤔 ).

Should make it easier to update to AGP 7.0.0 when it is stable (unless doing it pre stable is OK in which case I would just do that).