SonarLint showed "!unknown!::this.!unknownMethod!" as a suggestion for replacing method reference

Please provide

  • Operating system: Windows 10
  • SonarLint plugin version:
  • Is connected mode used: No
    • Connected to SonarCloud or SonarQube (and which version):

And a thorough description of the problem / question:

When using Android Studio with Java code, I experienced an issue where SonarLint correctly spotted a case where a lambda could be converted to a method reference, but it gave the method reference as “!unknown!::this.!unknownMethod!”, and when using the quick action, it replaced the lambda with this (which caused a compilation error).

The issue seems to be related to using an Android R value within the method call which accepts the lambda. I have got a reproducible example as follows:

public class Example {
    public void foo() {


    public void bar(int iconResourceId, Runnable runnable) {


    protected void baz() {
        Runnable r = () -> bar(, () -> foo());;

Here, was a simple string defined within my app. The same issue didn’t occur when using strings from android.R (for example “android.R.string.yes” which is defined in the Android framework rather than my app). However it happens with any resource that’s defined within my app.

I am on the latest version of Android Studio (Chipmunk Patch 1).

The specific message displayed by SonarLint is:

Replace this lambda with method reference '!unknown!.this::!unknownMethod!'.

It should have displayed:

Replace this lambda with method reference 'Example.this::foo'.

Hi @Adam_Burley, thanks for reporting the issue.

I managed to reproduce it locally and created a ticket to fix the problem.