2

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
Bitwise DEVS
  • 2,858
  • 4
  • 24
  • 67
  • what is the type of `someList`? and how is `model` declared? – Naman May 23 '21 at 07:02
  • @Naman same type `List` coming from the Intent. I tried to keep the model in proguard as well and it did not work, clearly it is not the POJO that has the problem. – Bitwise DEVS May 24 '21 at 08:05
  • 1
    Should be fixed in this bug https://issuetracker.google.com/issues/189264383 not officially released yet though – Roberto Jun 18 '21 at 11:54
  • 1
    @BitwiseDEVS, I have the same problem. Did you find the solution? I'm using AGP 7.0.4 and it didn't work. – Misagh Emamverdi Dec 28 '21 at 09:29

1 Answers1

1

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

taotao
  • 747
  • 9
  • 11