Search code examples
androidretrolambda

Lambda method reference to Function<F,T> throws NoClassDefFoundError


I am using Retrolambda for Android with Java 8 and I ran into a runtime fatal exception when saving a lambda method reference into Android's Function<F,T> interface throwing a java.lang.NoClassDefFoundError.

After wasting some time checking my own code, I actually realized that this interface is using javax.annotation.Nullable which has been moved to another dependency, causing it to not display any compilation errors, but throwing the mentioned exception at runtime.


Solution

  • My solution was just to create my own copy of the Function interface with the right Nullable import.