I can use retrolambda to enable lambdas with Android API level <24. So this works
myButton.setOnClickListener(view -> Timber.d("Lambdas work!"));
This also works
Runnable runLater = () -> Timber.d("Lambdas work!");
runLater.run();
But this one does not
Consumer<Integer> runLaterWithInt = (Integer i) -> Timber.d("i = " + i);
runLaterWithInt.accept(3);
The last one works on Android API Level 24, but on other devices this code causes a crash
java.lang.NoClassDefFoundError: com.retrolambdatry.MainActivity$$Lambda$1
Instead of using retrolambda I tried to enable Java 8. First two code examples still work, although butterknife stopped working. https://developer.android.com/preview/j8-jack.html#configuration here ava.util.function
is said to be supported, but I still get a crash when running the third one, this time it is a little different
java.lang.NoClassDefFoundError: com.retrolambdatry.MainActivity$-void_onCreate_android_os_Bundle_savedInstanceState_LambdaImpl1