Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AGP 7.0.0-alpha13: lint task fails #408

Closed
ubuntudroid opened this issue Apr 7, 2021 · 20 comments
Closed

AGP 7.0.0-alpha13: lint task fails #408

ubuntudroid opened this issue Apr 7, 2021 · 20 comments

Comments

@ubuntudroid
Copy link

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.

@pablisco
Copy link

pablisco commented Apr 9, 2021

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

@ubuntudroid
Copy link
Author

@pablisco Thanks for the heads-up! Unfortunately I can't try this out right now as we can't update to alpha-14 just yet. Will report back as soon as I can do the update.

@dschwemleinST
Copy link

dschwemleinST commented Apr 12, 2021

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.

@ubuntudroid
Copy link
Author

@pablisco @dschwemleinST for me it works just fine again with alpha-14 even without enableParallelLint=false. So I'd like to close this issue. Please double check, @dschwemleinST and confirm that it really doesn't work for you after a clean build.

@dschwemleinST
Copy link

@ubuntudroid Thank you for following up! It does appear to work after a few clean/builds using alpha-14 without enableParallelLint=false.

@ubuntudroid
Copy link
Author

My bad, I didn't test on CLI/CI. 🤦 There it still does not work. So I have to keep the issue open. 😞 android.enableParallelLint=false indeed does work as a workaround though.

@ubuntudroid
Copy link
Author

@dschwemleinST That's interesting. I can confirm, that cleaning fixes things locally. However on CI it still doesn't work despite cleaning all caches... 🤔

@dschwemleinST
Copy link

@ubuntudroid Exact same behavior here - it worked locally but once it failed on CI I removed my comment because I thought I must have been mistaken. So for now I am using alpha14 with the android.enableParallelLint=false workaround.

@ubuntudroid
Copy link
Author

Very confusing. Even adding a gradle clean to the CI build workflow didn't fix it there... I think I'll disable Timber lint checks for now, as disabling parallel lint in general would slow down builds on all machines and the Timber checks are mostly geared towards new Timber users anyway.

@NitroG42
Copy link

As it seems the error happened with alpha13-14, I made a reported the bug on the APG side => https://issuetracker.google.com/issues/184565320
But without answer for now.

@NitroG42
Copy link

Last follow up, as it seems the issue escalated!

It is an issue that needs to be fixed in Timber, yes. Timber will need to be updated to be compatible with Lint / AGP 7.0.

mbarrben added a commit to mbarrben/moviedb that referenced this issue May 20, 2021
@mengdd
Copy link

mengdd commented Jun 2, 2021

Found the reason might due to getMainProject:
See:
http://googlesamples.github.io/android-custom-lint-rules/api-guide.md.html
For this section: Catching Mistakes: Blocking Access to Main Project

@Mehly
Copy link

Mehly commented Jun 18, 2021

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'

@eygraber
Copy link
Contributor

Getting #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).

@petedoyle
Copy link

Probably a red herring- I updated to AGP/lint 7.0.0-beta03 a few days ago and it's worked fine on both MacOS and Linux/CI (where every build gets a clean container.)

However, I just tried disabling Jetifier (our project is finally there 🙌) and this popped up. FYI in case it's related.

msasikanth pushed a commit to simpledotorg/simple-android that referenced this issue Jul 29, 2021
Partial Analysis : http://googlesamples.github.io/android-custom-lint-rules/api-guide.html#partialanalysis

Currently Timber lint has issue when partial analysis is enabled, we can re-enable the partial analysis once Timber is updated with a fix.
JakeWharton/timber#408
msasikanth pushed a commit to simpledotorg/simple-android that referenced this issue Jul 29, 2021
Partial Analysis : http://googlesamples.github.io/android-custom-lint-rules/api-guide.html#partialanalysis

Currently Timber lint has issue when partial analysis is enabled, we can re-enable the partial analysis once Timber is updated with a fix.
JakeWharton/timber#408
msasikanth pushed a commit to simpledotorg/simple-android that referenced this issue Jul 29, 2021
* Bump AGP to v7.0.0

* Bump Gradle wrapper to v7.0.2

* Replace deprecated Gradle usages

* Disable Lint partial analysis

Partial Analysis : http://googlesamples.github.io/android-custom-lint-rules/api-guide.html#partialanalysis

Currently Timber lint has issue when partial analysis is enabled, we can re-enable the partial analysis once Timber is updated with a fix.
JakeWharton/timber#408

* Enable checking dependencies when running lint

This will be default in AGP 7.1.0

* Enable core library desugaring in platform module

* Remove unused resources in router module

* Bump Lint to v30.0.0

* Add `Vendor` in `SimpleIssueRegistry`

* Update CHANGELOG
@AlanChiou
Copy link

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'

@eygraber
Copy link
Contributor

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

david-allison added a commit to david-allison/Anki-Android that referenced this issue Jul 31, 2021
Timber Lint is currently incompatible with AGP 7

See: JakeWharton/timber#408

Related: 9338
mikehardy pushed a commit to ankidroid/Anki-Android that referenced this issue Jul 31, 2021
Timber Lint is currently incompatible with AGP 7

See: JakeWharton/timber#408

Related: 9338
@mohsenoid
Copy link

Any update on this issue?

@arlindiDev
Copy link

arlindiDev commented Aug 9, 2021

Im guessing we have to wait until this commit gets released. Here is the PR (already merged) for that commit.

From the Android Lint API guide, the section:

8.4.1 Catching Mistakes: Blocking Access to Main Project

states that using getMainProject() will fail with that error that we are seeing.

In that already merged PR, the change from using getMainProject() to getProject() should fix this issue?
Here is the line of code that was changed to use getProject().

What is the difference between calling getMainProject() vs getProject()?
Would the getProject().minSdkVersion() < 25 only be true/valid only for non application modules.

@JakeWharton
Copy link
Owner

Fix is merged but not yet released.

krmanik pushed a commit to krmanik/Anki-Android that referenced this issue Aug 24, 2021
Timber Lint is currently incompatible with AGP 7

See: JakeWharton/timber#408

Related: 9338
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests