Filter a list of objects in Android using gradle-retrolambda and Lightweight-Stream-API
<p>I am trying to filter a List of Objects in Java in my Android App, for this I followed <a href="https://stackoverflow.com/a/13140130/3546389">this answer</a> (Java 8 suggestion) , but as Lambdas aren't supported in Android SDK, I used <a href="https://github.com/evant/gradle-retrolambda" rel="nofollow noreferrer">gradle-retrolambda</a> but I get this runtime-error<br>
<code>java.lang.NoSuchMethodError: No interface method stream()Ljava/util/stream/Stream; in class Ljava/util/List; or its super classes (declaration of 'java.util.List' appears in /system/framework/core-libart.jar)</code>  </p>

<p>This is the line of code I am using:  </p>

<pre><code>List&lt;CaseDetails&gt; closedCaseDetailsList = caseDetailsList.stream().filter(item -&gt; item.caseClosed.equals(true)).collect(Collectors.toList());
</code></pre>

<p>I believe it should work as <strong>gradle-retrolambda</strong> should be taking care of the Lambdas on Java7.  </p>

<p>Next, I tried <a href="https://github.com/aNNiMON/Lightweight-Stream-API" rel="nofollow noreferrer">Lightweight-Stream-API</a> along with <strong>gradle-retrolambda</strong> and changed my code a little, according to the usage of Lightweight-Stream-API</p>

<pre><code>List&lt;CaseDetails&gt; closedCaseDetailsList = Stream.of(caseDetailsList).filter(item -&gt; item.caseClosed.equals(true)).collect(Collectors.toList());  
</code></pre>

<p>But it gives me an error over <code>Collectors.toList()</code> saying </p>

<pre><code>collect
(com.annimon.stream.Collector&lt;? super com.example.yankee.cw.CaseDetails,java.lang.Object,java.lang.Object&gt;)
in Stream cannot be applied
to
 (java.util.stream.Collector&lt;T,capture&lt;?&gt;,java.util.List&lt;T&gt;&gt;) 
</code></pre>

<p>I also tried explicitly type-casting the <code>Stream</code> to <code>List&lt;CaseDetails&gt;</code> but that didn't work (of course).</p>

<p>I tried Slack communities, SO Chat-rooms but couldn't find a solution. The closest thing I found to my problem was this <a href="https://stackoverflow.com/questions/36788152/android-nosuchmethoderror-with-static-method-in-interface-using-retrolambda">question</a> but it is a different error.<br>
Thanks </p>