Just started using lambdas in a new project and stuck with the issue when app crashes with the following stack trace:
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.test.-$Lambda$3>
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test, PID: 18852
java.lang.NoClassDefFoundError: com.test.-$Lambda$3
... method which calls lambda ...
The interesting thing is it works sometimes but I still can't figure out what makes it work and what breaks.
jackOptions
and 1.8 compatibility
are both enabled in build.gradle. compileSdkVersion
is 25. Device is running Android 5.0. The resulting apk has this com.test.-$Lambda$3
class defined.
Is there anything that should be done in addition to completely enable lambdas? How to debug this issue to find out the real root cause?
Update 1:
It sounds pretty strange but looks like compiler messes with lambda calls. Say the resulting APK has $Lambda$1:Runnable
and $Lambda$2:Consumer
defined and I see particular method calls $Lambda$1
while it has to be $Lambda$2
.