fix(map): apply kotlinx-serialization compiler plugin to androidApp#5726
Merged
Conversation
androidApp pulled in the kotlinx-serialization runtime but never applied the org.jetbrains.kotlin.plugin.serialization compiler plugin. The @serializable annotation was therefore inert — no $serializer was generated — so code compiled but Json.encodeToString fell back to a reflective lookup at runtime and threw: SerializationException: Serializer for class 'CustomTileProviderConfig' is not found. Please ensure that class is marked as '@serializable' and that the serialization compiler plugin is applied. This crashed when saving custom tile providers (CustomTileProviderRepositoryImpl.saveDataToPrefs). MapCameraPosition had the same latent bug. Applying the shared meshtastic.kotlinx.serialization convention plugin — as the other 16 serializing modules already do — generates the serializers and fixes both. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Crashlytics is reporting a runtime crash in the latest build:
Root cause
The class is annotated
@Serializable— this is not a missing annotation, nor an R8/minification issue. TheandroidAppmodule pulled in the kotlinx-serialization runtime (kotlinx-serialization-json) but never applied the compiler plugin (org.jetbrains.kotlin.plugin.serialization).Without the compiler plugin,
@Serializableis inert — no$serializeris synthesized. The code still compiles (the annotation andJsonresolve from the runtime lib), butJson.encodeToStringfalls back to a reflective serializer lookup at runtime, finds nothing, and throws the exception above. Note the tail of the message: "…and that the serialization compiler plugin is applied."Every other module that serializes (16 of them across
core/*andfeature/*) applies the sharedmeshtastic.kotlinx.serializationconvention plugin.androidAppwas the lone exception. The bug only surfaced now because the custom-tile-provider save path is rarely exercised — it would crash in debug too.MapCameraPosition(also@SerializableinandroidApp) had the same latent bug.Fix
Apply the existing
meshtastic.kotlinx.serializationconvention plugin toandroidApp, exactly as the other serializing modules do. The convention plugin addsserialization-corewhenkotlin.androidis present (composes cleanly with the existingserialization-jsondep) and applies the compiler plugin so$serializerclasses are generated for all@Serializabletypes in the module.Verification
./gradlew spotlessCheck detekt :androidApp:assembleGoogleDebug— pass (the affected classes live insrc/google)🤖 Generated with Claude Code