I am trying to access RealmList of model class in forEach
loop.
Attempt : 1
realmList.forEach(obj -> { System.out.println("value"+obj.getValue())});
Attempt : 2
realmList.forEach((ModelClass obj) -> { System.out.println("value"+obj.getValue())});
On both attempt i got error
java.lang.NoClassDefFoundError:activites.MainActivity$$Lambda$1
how do i resolve this error?
Retrolambda just provides the syntax from Java 8, not API. So new Date&Time API, Streams API, etc. will not be available with just using Retrolambda. If you want to use new Java 8 APIs in Android you have to add additional libs besides Retrolambda. Very nice port of Stream API is on https://github.com/aNNiMON/Lightweight-Stream-API
In addition : if you want to use newest Java 8 Date API in Android you can use this port : http://www.threeten.org/threetenbp/
EDIT
I have an impression that my previous answer was not 100% clear. Your problem now is that you want to use ArrayList.forEach method which is unavailable in Java 7 which is used in Android SDK. Android Studio displays such completions as it thought that you are using Jack compiler and these API is available. But you need to ignore that and use one of Java 8 APIs port or switch to Jack compiler which allows you to use Java 8 syntax and APIs without Retrolambda.