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

Cannot resolve method 'plant(timber.log.Timber.DebugTree)' #459

Closed
findyourexit opened this issue Feb 14, 2022 · 12 comments
Closed

Cannot resolve method 'plant(timber.log.Timber.DebugTree)' #459

findyourexit opened this issue Feb 14, 2022 · 12 comments

Comments

@findyourexit
Copy link

  • Android Studio version: Android Studio Bumblebee | 2021.1.1 Patch 1 (Build #AI-211.7628.21.2111.8139111)
  • Timber version: com.jakewharton.timber:timber:5.0.1

Reproduction steps:

  1. Simply add the above dependency to an Android project (ensuring to use Android Studio Bumblebee+)
  2. Observe the Cannot resolve method 'plant(timber.log.Timber.DebugTree)' Lint error message:

image

Additional notes:

  • Didn't seem to occur on prior version of Android Studio (Arctic Fox and prior).
  • Does seem to affect Android Studio Bumblebee (Stable), Chipmunk (Beta) and Dolphin (Canary).
  • Doesn't appear to occur with pre-5.0.0 versions of Timber.
  • Loosely related to this issue.
  • Could be an Android Studio bug rather than a bug with Timber, though I figured best to report it here as it doesn't seem to affect pre-5.0.0 versions of Timber as mentioned previously.
  • In case the issue is in fact with Android Studio, @gmk57 has reported it on Android Studio bug tracker.
@gmk57
Copy link

gmk57 commented Feb 14, 2022

If anybody could try to reproduce it in Intellij IDEA, that might me helpful. The issue may be neither in Timber nor in AS, but in Kotlin plugin, and in that case should be reported to JetBrains.

@JakeWharton
Copy link
Owner

Are you calling from a Java or Kotlin source file?

@gmk57
Copy link

gmk57 commented Feb 14, 2022

This only happens when calling from Java.

@NizarETH
Copy link

Same issue too

Capture d’écran 2022-02-22 à 16 39 00

@uvery9
Copy link

uvery9 commented Mar 13, 2022

Convert Java File to Kotlin File can easily solve the problem.
image

@findyourexit
Copy link
Author

Convert Java File to Kotlin File can easily solve the problem. image

This is not a solution, this is a workaround.

@niklasdahlheimer
Copy link

This issue has also been discussed here.

@gmk57 has mentioned a ticket in the Android Studio bugtracker. The Google engineer noted that it could be an issue that Timber.plant() and Timber.DebugTree() resolve to different files:
Timber.plant get resolved to a binary .class while new Timber.DebugTree - to the sources, even if these 2 methods are in the same file. So it may be caused by the plugin itself or a way Android Studio attaches .aar libraries.

Probably also related to this bug in the kotlin plugin

Maybe this helps to find the cause of this issue?

@killvetrov
Copy link

Let's be clear that this is just false positive highlighting in IDEA, code compiles fine. Title/comments of this issue make it look like a more severe problem. It is not specific to Timber, it manifests with many other Kotlin-first libraries consumed in Java code.

The issue is related to IDEA Kotlin plugin:
https://youtrack.jetbrains.com/issue/KTIJ-19699/IDE-False-positive-type-mismatch-in-Java-code-for-Kotlin-nested-class-non-direct-inheritor-from-external-library

Currently in backlog for next IDEA release 2022.2.

@Quyunshuo
Copy link

Same problem, but we can wrap the initialization code with a Kotlin class.

@killvetrov
Copy link

The issue is related to IDEA Kotlin plugin: https://youtrack.jetbrains.com/issue/KTIJ-19699/IDE-False-positive-type-mismatch-in-Java-code-for-Kotlin-nested-class-non-direct-inheritor-from-external-library

So recently this issue had been marked as fixed, stating that compiling libraries with Kotlin compiler 1.8 resolves this (properly writes InnerClasses attribute, details in recent issue comments). It is discussed whether Idea may get a workaround for highlighting of libraries compiled with earlier versions.

Again, to reiterate, this only concerns usage of Kotlin libraries in Java code, and is not Timber-specific issue. So I think this issue can be closed.

@Chivorns
Copy link

Chivorns commented Feb 8, 2023

For workaround solution to avoid annoying warning message every time we stay on our Java class and to avoid the class appear in red color as it might confused with the error, I think you can try with my answer here: https://stackoverflow.com/a/75388643/7257373

@androidacy-user
Copy link

The issue is related to IDEA Kotlin plugin: https://youtrack.jetbrains.com/issue/KTIJ-19699/IDE-False-positive-type-mismatch-in-Java-code-for-Kotlin-nested-class-non-direct-inheritor-from-external-library

So recently this issue had been marked as fixed, stating that compiling libraries with Kotlin compiler 1.8 resolves this (properly writes InnerClasses attribute, details in recent issue comments). It is discussed whether Idea may get a workaround for highlighting of libraries compiled with earlier versions.

Again, to reiterate, this only concerns usage of Kotlin libraries in Java code, and is not Timber-specific issue. So I think this issue can be closed.

still would be awesome for timber to fix the issue - as stated in the google issue tracker, it needs compiled with a newer compiler to fix the issue. IntelliJ is hardly going to work around it themeselves.

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

10 participants