Thursday, November 6, 2014

Android Studio/IntelliJ false error Object.getClass() shows as ambiguous method call

Tired of seeing this issue? Yes, it's terrible because it creates a lot noise for us to find the real errors. And we don't want to bend our code to remove the redness in the IDE with this hack - ((Object)this).getClass(). Solution: Link into the source code by clicking getClass() in your IDE. We should see the code below
    public final Class<?> getClass() {//Remove <?>
      return shadow$_klass_;
    }
Remove the <?> and refresh the project. The red lines should be gone.
    public final Class getClass() {//<?> removed
      return shadow$_klass_;
    }