question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NoSuchMethodError: No static method removeIf

See original GitHub issue

Describe the bug We use Coil indirectly via https://github.com/GetStream/stream-chat-android and we are seeing lots of crashes with that exception:

Fatal Exception: java.lang.NoSuchMethodError: No static method removeIf(Ljava/util/Collection;Lj$/util/function/Predicate;)Z in class Lj$/util/Collection$-EL; or its super classes (declaration of 'j$.util.Collection$-EL' appears in base.apk!classes2.dex)
       at coil.memory.RealWeakMemoryCache.cleanUp$coil_base_release(WeakMemoryCache.kt:173)

Since Stream could not help us with this so far, we are reaching out to you. We cannot reproduce the crash consistently, but for some users it happens quite often.

This looks like some Java 8 issue since this method is new in Java 8. We have enabled Java 8 compatibility in our project and Stream has it also in their SDK.

Excerpt from our build.gradle:

compileOptions {
    coreLibraryDesugaringEnabled true
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = '1.8'
}

And from the Stream SDK: https://github.com/GetStream/stream-chat-android/blob/4.19.0/stream-chat-android-core/build.gradle#L18

So if you have any ideas what is happening here, we would really appreciate it. Thank you!

Logs/Screenshots

Fatal Exception: java.lang.NoSuchMethodError: No static method removeIf(Ljava/util/Collection;Lj$/util/function/Predicate;)Z in class Lj$/util/Collection$-EL; or its super classes (declaration of 'j$.util.Collection$-EL' appears in base.apk!classes2.dex)
       at coil.memory.RealWeakMemoryCache.cleanUp$coil_base_release(WeakMemoryCache.kt:173)
       at coil.memory.RealWeakMemoryCache.trimMemory(WeakMemoryCache.kt:145)
       at coil.RealImageLoader.onTrimMemory(RealImageLoader.kt:205)
       at coil.util.SystemCallbacks.onTrimMemory(SystemCallbacks.kt:46)
       at android.app.Application.onTrimMemory(Application.java:306)
       at android.app.ActivityThread.handleTrimMemory(ActivityThread.java:6956)
       at android.app.ActivityThread.access$1300(ActivityThread.java:301)
       at android.app.ActivityThread$ApplicationThread.lambda$scheduleTrimMemory$0(ActivityThread.java:1792)
       at android.app.-$$Lambda$ActivityThread$ApplicationThread$tUGFX7CUhzB4Pg5wFd5yeqOnu38.accept(:8)
       at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:278)
       at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:201)
       at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:97)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1010)
       at android.view.Choreographer.doCallbacks(Choreographer.java:809)
       at android.view.Choreographer.doFrame(Choreographer.java:746)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:995)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8595)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Version 1.2.1 and 1.3.2 (we tried different Stream SDK versions). Seems to happen mainly on Samsung devices.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
colinrtwhitecommented, Oct 6, 2021

@zsmb13 Actually main’s in a good state for a release so I just pushed 1.4.0 which contains the fix!

1reaction
colinrtwhitecommented, Oct 6, 2021

@zsmb13 It should be out pretty soon, but I can’t give an ETA. If you need the fix now, you should use the latest snapshot.

Also I still think this is a local desugaring issue as we use coreLibraryDesugaringEnabled=true at Instacart and don’t experience this crash.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.NoSuchMethodError: No static method 'myMethod'
The app installs without any errors; but when the method is invoked at runtime it gives me the following error: java.lang.NoSuchMethodError: No ......
Read more >
Android: NoSuchMethodError · Issue #464 · mapbox ... - GitHub
We have reverted the API breaking changes in master inside the map, Mapbox Java, and nav SDKs. LocationEngine related issues should be resolved ......
Read more >
Java 8+ APIs available through desugaring
Through a process called API desugaring, the DEX compiler (D8) allows you to include more standard language APIs in apps that support older ......
Read more >
New Feature - Release Notes - Java Bug System
[JDK-6391197] - static import seems to hide non-static import in a very special case ... Missing cast in method reference bridge leads to...
Read more >
What is ArrayList.removeIf() method in Java? - Educative.io
In the code above, we created a numbers ArrayList and added some positive and negative numbers to it. Then, we passed a predicate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found