1

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$3class 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.

Mikhail
  • 568
  • 1
  • 6
  • 22
  • Not so familiar with Android but I think Android doesn't support java-8 yet. Also it seems weird the error that your app yields. The definition of the Lambda seems weird. Can you share the code too? Worth to check https://developer.android.com/guide/platform/j8-jack.html – xiumeteo Mar 15 '17 at 23:33
  • @xiumeteo I've done everything according tot that guide. The funny thing it was working till some point and then suddenly stopped, then started again and then stopped completely. – Mikhail Mar 15 '17 at 23:52

0 Answers0