android-client icon indicating copy to clipboard operation
android-client copied to clipboard

GsonPreconditions: NoClassDefFoundError

Open dostalleos opened this issue 6 months ago • 1 comments

It appears that you are using a deprecated method from the GSON library. It's GsonPreconditions.checkNotNull().

 @Deprecated
  public static <T> T checkNotNull(T obj) {
    if (obj == null) {
      throw new NullPointerException();
    }
    return obj;
  }

After some dependency updates, we started getting this crash immediately when the app starts, and the Split client is initiated. I think some other library updated the GSON version, where that class is already removed. Please, see the stacktrace below.

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/internal/$Gson$Preconditions;
	at io.split.android.client.service.sseclient.sseclient.SseRefreshTokenTimer.<init>(SseRefreshTokenTimer.java:24)
	at io.split.android.client.SplitFactoryHelper.getPushNotificationManager(SplitFactoryHelper.java:259)
	at io.split.android.client.SplitFactoryHelper.buildStreamingComponents(SplitFactoryHelper.java:371)
	at io.split.android.client.SplitFactoryImpl.<init>(SplitFactoryImpl.java:215)
	at io.split.android.client.SplitFactoryImpl.<init>(SplitFactoryImpl.java:104)
	at io.split.android.client.SplitFactoryBuilder.build(SplitFactoryBuilder.java:67)

Your library uses com.google.code.gson:gson:2.10.1 but our other dependency uses com.google.code.gson:gson:2.13.0.

Could you please update the GSON and fix this issue? Thank you

dostalleos avatar May 09 '25 10:05 dostalleos

Based on this: https://github.com/google/gson/releases/tag/gson-parent-2.13.0, you use the internal GSON class, that was renamed.

dostalleos avatar May 09 '25 10:05 dostalleos

+1, this has become an issue for our app after updating other libraries that provide Gson 2.13.0 as a transitive dependency (e.g., https://github.com/intercom/intercom-android/releases/tag/15.16.1).

Please prioritize this issue

seankim-android avatar May 12 '25 00:05 seankim-android

Hi @dostalleos, thanks for flagging this. We'll take a look.

gthea avatar May 12 '25 13:05 gthea

@gthea, thanks for your response. Do you have any updates on the timeline by chance?

seankim-android avatar May 20 '25 03:05 seankim-android

Version 5.3.0-rc1 is available and should fix this; stable will be out by next week.

gthea avatar May 21 '25 18:05 gthea

Hi @dostalleos, @seankim-android, version 5.3.0 has been released with a fix for this.

gthea avatar May 28 '25 21:05 gthea