Skip to content

fix(map): apply kotlinx-serialization compiler plugin to androidApp#5726

Merged
jamesarich merged 1 commit into
mainfrom
claude/quirky-feynman-8f14a6
Jun 3, 2026
Merged

fix(map): apply kotlinx-serialization compiler plugin to androidApp#5726
jamesarich merged 1 commit into
mainfrom
claude/quirky-feynman-8f14a6

Conversation

@jamesarich
Copy link
Copy Markdown
Collaborator

Problem

Crashlytics is reporting a runtime crash in the latest build:

kotlinx.serialization.SerializationException: Serializer for class 'CustomTileProviderConfig' is not found.
Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.
  ...
  kotlinx.serialization.json.Json.encodeToString(Json.java:205)
  org.meshtastic.app.map.repository.CustomTileProviderRepositoryImpl$saveDataToPrefs$2.invokeSuspend(CustomTileProviderRepository.kt:97)

Root cause

The class is annotated @Serializable — this is not a missing annotation, nor an R8/minification issue. The androidApp module pulled in the kotlinx-serialization runtime (kotlinx-serialization-json) but never applied the compiler plugin (org.jetbrains.kotlin.plugin.serialization).

Without the compiler plugin, @Serializable is inert — no $serializer is synthesized. The code still compiles (the annotation and Json resolve from the runtime lib), but Json.encodeToString falls 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/* and feature/*) applies the shared meshtastic.kotlinx.serialization convention plugin. androidApp was 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 @Serializable in androidApp) had the same latent bug.

Fix

Apply the existing meshtastic.kotlinx.serialization convention plugin to androidApp, exactly as the other serializing modules do. The convention plugin adds serialization-core when kotlin.android is present (composes cleanly with the existing serialization-json dep) and applies the compiler plugin so $serializer classes are generated for all @Serializable types in the module.

Verification

  • ./gradlew spotlessCheck detekt :androidApp:assembleGoogleDebug — pass (the affected classes live in src/google)

🤖 Generated with Claude Code

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>
@github-actions github-actions Bot added the bugfix PR tag label Jun 3, 2026
@jamesarich jamesarich merged commit 0e4f12e into main Jun 3, 2026
16 checks passed
@jamesarich jamesarich deleted the claude/quirky-feynman-8f14a6 branch June 3, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant