Skip to content

Fix the crash on older Android versions without desugaring - #381

Open
Keith-wright wants to merge 2 commits into
masterfrom
fix-android-api-21
Open

Keith-wright wants to merge 2 commits into
masterfrom
fix-android-api-21

Conversation

@Keith-wright

@Keith-wright Keith-wright commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #366. Since 2.4.1, the library has used java.util.function.Consumer, which only exists on Android 7 and later, so creating Pusher crashed on older versions without core library desugaring. This replaces it with an internal interface. The README is unchanged.

Requesting the release-patch label for 2.4.6.

CHANGELOG

Since 2.4.1 the connection passed events through java.util.function.Consumer,
which only exists on Android 7 (API 24) and later. On API 21 to 23 the lambda
that implements it fails to load, so creating Pusher threw
NoClassDefFoundError unless the app enabled core library desugaring.

Use a library interface instead, so the client runs on Android 5 (API 21)
and later without desugaring, as it did before 2.4.1.

Fixes #366

@aonemd aonemd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? Both Android 5 and 6 support has ended by Google.

Android 5 and 6 are past Google's support, and current AndroidX libraries
default to minSdk 24, so don't advertise them as supported. The code change
still removes the crash on older versions.
@Keith-wright Keith-wright changed the title Support Android 5 and 6 without desugaring Fix the crash on older Android versions without desugaring Oct 22, 2026
@Keith-wright

Copy link
Copy Markdown
Contributor Author

@aonemd You’re right. I’ve reverted the README change, so it still says Android 7 and above, and I’ve updated the PR title to match.

The code change is still worth keeping. java.util.function.Consumer was added in API 24, so since 2.4.1 the library has crashed on older versions without desugaring (#366). An internal interface fixes that, with no change on Android 7 and up.

This PR also carries the #288 fix from #349 for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

java.lang.NoClassDefFoundError: com.pusher.client.Pusher$$ExternalSyntheticLambda0 on Android API 21-22 anyway

2 participants