Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in InsightsEventDOMapper when obfuscating with R8 due to Kotlinx Serializer #401

Closed
tbra91 opened this issue Aug 15, 2023 · 2 comments 路 Fixed by #402
Closed

Crash in InsightsEventDOMapper when obfuscating with R8 due to Kotlinx Serializer #401

tbra91 opened this issue Aug 15, 2023 · 2 comments 路 Fixed by #402

Comments

@tbra91
Copy link
Contributor

tbra91 commented Aug 15, 2023

Describe the bug 馃悰
InsightsEventDOMapper is crashing when obfuscating with R8 due to the Kotlinx Serializer. I have managed to workaround it by adding the following Proguard rules:

-keep,includedescriptorclasses class com.algolia.instantsearch.insights.internal.data.local.model.InsightsEventDO$$serializer { *; }
-keepclassmembers class com.algolia.instantsearch.insights.internal.data.local.model.InsightsEventDO {
    *** Companion;
}
-keepclasseswithmembers class com.algolia.instantsearch.insights.internal.data.local.model.InsightsEventDO {
    kotlinx.serialization.KSerializer serializer(...);
}

I believe the fix should be to change the serialization calls in InsightsEventDOMapper to pass InsightsEventDO.serializer() as the first parameter.

Environment:

  • Library version: 3.3.0

Additional context

Stack trace:

Fatal Exception: kotlinx.serialization.SerializationException: Serializer for class 'b' is not found.
Mark the class as @Serializable or provide the serializer explicitly.
       at kotlinx.serialization.internal.Platform_commonKt.serializerNotRegistered(Platform.common.kt:91)
       at kotlinx.serialization.internal.PlatformKt.platformSpecificSerializerNotRegistered(Platform.kt:29)
       at kotlinx.serialization.SerializersKt__SerializersKt.serializer(Serializers.kt:60)
       at kotlinx.serialization.SerializersKt.serializer(Serializers.kt:1)
       at com.algolia.instantsearch.insights.internal.data.local.mapper.InsightsEventDOMapper.map(InsightsEventDOMapper.kt:20)
       at com.algolia.instantsearch.insights.internal.data.local.InsightsPrefsRepository.asJsonString(InsightsPrefsRepository.kt:21)
       at com.algolia.instantsearch.insights.internal.data.local.InsightsPrefsRepository.append(InsightsPrefsRepository.kt:16)
       at com.algolia.instantsearch.insights.internal.cache.InsightsEventCache.save(InsightsEventCache.kt:11)
       at com.algolia.instantsearch.insights.internal.InsightsController.track(InsightsController.kt:180)
       at com.algolia.instantsearch.insights.internal.InsightsController.clicked(InsightsController.kt:173)
       at com.algolia.instantsearch.insights.internal.InsightsController.clickedObjectIDsAfterSearch(InsightsController.kt:115)
       at com.algolia.instantsearch.insights.HitsAfterSearchTrackable$DefaultImpls.clickedObjectIDsAfterSearch$default(HitsAfterSearchTrackable.kt:57)
tbra91 added a commit to tbra91/instantsearch-android that referenced this issue Aug 15, 2023
@KubaPreg
Copy link

bump! Anyone got any ETA on fixing this? Any way around until it's fixed?

@tbra91
Copy link
Contributor Author

tbra91 commented Nov 9, 2023

@KubaPreg see the Proguard rules in my original post for a workaround.

github-merge-queue bot pushed a commit that referenced this issue Dec 6, 2023
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 a pull request may close this issue.

2 participants