Tapping the logo in the map's corner crashed the app: Naver Map SDK and the AppCompat theme
Four "You need to use a Theme.AppCompat theme" crashes showed up in Crashlytics for our lottery store map app. They came not from users but from the Play pre-launch report's test robot tapping the NAVER logo in the bottom-left corner of the map. The cause, a fix that wraps only the map instead of changing the whole app theme, and a second problem that appeared in dark mode.
The first crash
On the evening of October 17, a crash we had never seen showed up in Crashlytics for our lottery store map app.
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme
(or descendant) with this activity.
at com.naver.maps.map.widget.LogoView$3.onClick
When we counted again on October 19, there were 4 events from 2 affected users in the last 14 days: 3 on version 1.0.78 and 1 on 1.0.79, all on a OnePlus 8 Pro running Android 11. We often see that device used by the test robot in Play's pre-launch report, which taps through the app automatically. None of the events came from a real user's device.
We did not skip it just because a robot found it. The stack was inside the map SDK, not our code, and all the robot did was tap something visible on screen, so a user tapping the same spot would crash the same way.
Tapping the logo opens an SDK dialog
The Naver Map SDK draws a NAVER logo in the bottom-left corner of the map. Tapping it makes the SDK open a dialog with SDK information, a map legend, legal notices and open source licenses. That dialog comes from androidx.appcompat, so the screen showing it needs an AppCompat theme.
Our app draws every screen with Jetpack Compose, and the Compose theme decides the colors. So we kept the activity theme light, only setting the window background.
<style name="Theme.Lotto" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:windowBackground">@color/window_bg</item>
...
</style>
android:Theme.Material is not an AppCompat theme. Showing the map, scrolling and tapping markers all worked; only when the logo was tapped did the dialog check the theme and throw. We had never tapped the logo during development, so we did not know.
The fix: wrap only the map in AppCompat
We could have changed the parent of the whole app theme to AppCompat, but then every screen unrelated to the map would need checking again. The problem was in one view, the map, so we wrapped only the Context passed in when the map view is created.
<!-- for the map view only -->
<style name="Theme.LottoMap" parent="Theme.AppCompat.Light.NoActionBar" />
val mapView = remember {
MapView(ContextThemeWrapper(ctx, R.style.Theme_LottoMap)).also { it.onCreate(null) }
}
When MapView is created with a Context wrapped in ContextThemeWrapper, dialogs opened from inside the map use that theme, while the rest of the app keeps its original theme. We defined the style in the app's own themes.xml instead of pointing at library resources directly.
The second problem: unreadable text in dark mode
Since the app supports dark mode, we first wrapped the map with Theme.AppCompat.DayNight.NoActionBar. The crash was gone, but when we set a Galaxy Note10+ to dark mode and tapped the logo, the dialog background turned dark while the text color the SDK uses stayed dark, so the menu text was almost invisible.
So we fixed the map theme to Light. The dialog now opens light even in dark mode. It does not match the rest of the app, but we decided that was better than text nobody can read.
We installed a debug build on a Galaxy Note10+, tapped the logo, opened the dialog, then opened the legend, legal notices and open source licenses one by one, and saw no crash. We submitted this fix to Play as version 1.0.80 on October 18.
Other apps using the same SDK
Three more of our apps use Naver Map, so we checked their themes.
- Benefits app and dog app: the Material3 DayNight theme from Material Components
- Pill search app: an AppCompat DayNight theme
All three are AppCompat descendants, so they are not set up to hit this crash (we judged this from the themes; we did not tap the logo in those three apps). They are also all DayNight, and we have not yet checked whether the same dialog's text becomes unreadable in dark mode there.
Takeaways
- A library that lives inside your screen, like a map SDK, can open its own dialogs, and the theme those dialogs need can differ from your app theme.
- If your Compose app keeps the activity theme light with
android:Theme.Material, check whether any library opens AppCompat dialogs. - When fixing it, wrapping only the affected view in
ContextThemeWrapperavoids touching the whole app theme. - Open it in dark mode too. Library dialogs sometimes set their own text color, and if only the background turns dark, the text becomes unreadable.
- A crash from the pre-launch robot is a real defect when the stack points at "something a person can tap", even if the device isn't a real user's.
The app in this post is the lottery results and store map app on Google Play (Korean only).