The app crashes only in its release version with desugaring Java 8 for Android.
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
This is what we tried but did not work.
-keep class java.util.stream.** { *; }
The sample code is just using filter
List<MovieModel> = someList.stream().filter(it -> !it.getImdbId().equalsIgnoreCase(model.getImdbId())).collect(Collectors.toList())
Error:
java.lang.ClassCastException: j$.util.stream.p cannot be cast to j$.wrappers.p
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
tools:desugar_jdk_libs
should upgrade to 1.1.5 or heigher.https://developer.android.com/studio/write/java8-support.html