java.lang.RuntimeException: RichInputMethodManager is used before initialization
Describe the bug When going to Languages & layouts in Settings (before enabling the keyboard), the app crashes when I try to toggle any of the languages provided in the list. For example, if I turn on 'Danish', the app will crash. Here's the stacktrace below: FATAL EXCEPTION: main Process: helium314.keyboard, PID: 16569 java.lang.RuntimeException: RichInputMethodManager is used before initialization at helium314.keyboard.latin.RichInputMethodManager.checkInitialized(RichInputMethodManager.java:82) at helium314.keyboard.latin.RichInputMethodManager.getInstance(RichInputMethodManager.java:64) at helium314.keyboard.latin.utils.SubtypeSettingsKt.addEnabledSubtype(SubtypeSettings.kt:67) at helium314.keyboard.latin.settings.LanguageAdapter$ViewHolder.onBind$setupDetailsTextAndSwitch$lambda$5$lambda$4(LanguageFilterList.kt:128) at helium314.keyboard.latin.settings.LanguageAdapter$ViewHolder.$r8$lambda$b54j6Uq9IFrTladK48_cBbE4upQ(LanguageFilterList.kt:0) at helium314.keyboard.latin.settings.LanguageAdapter$ViewHolder$$ExternalSyntheticLambda3.onCheckedChanged(R8$$SyntheticClass:0) at android.widget.CompoundButton.setChecked(CompoundButton.java:235) at android.widget.Switch.setChecked(Switch.java:1390) at android.widget.Switch.toggle(Switch.java:1366) at android.widget.CompoundButton.performClick(CompoundButton.java:155) at android.view.View.performClickInternal(View.java:8024) at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0) at android.view.View$PerformClick.run(View.java:31890) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:230) at android.os.Looper.loop(Looper.java:319) at android.app.ActivityThread.main(ActivityThread.java:8919) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
To Reproduce
- Install heliboard apk and click on Enable in Settings in step 1
- Do not toggle heliboard yet but first click on Heliboard itself in the keyboard list settings
- Click on Languages & Layouts
- Disable 'Use System Languages'
- Toggle any of the languages from below
- Crashes and exits out of the settings
Expected behavior App should either not crash or not allow user to toggle languages in the first place
App version Tested in latest 2.3v stable build
Device:
- Model: Samsung A13
- OS: Android 14
Was able to find a fix for this Basically to not allow user to toggle with any language settings instead show a toast message saying something like "Please enable keyboard first and then select language". And not allow the toggle switch to turn on or off. In LanguageFilterList.kt can do something like this-
setOnCheckedChangeListener { _, b ->
if (KeyboardSwitcher.getInstance().isThisKeyboardEnabled(context)) {
if (b) {
if (!infos.first().hasDictionary)
showMissingDictionaryDialog(context, infos.first().subtype.locale())
addEnabledSubtype(prefs, infos.first().subtype)
infos.first().isEnabled = true
} else {
removeEnabledSubtype(prefs, infos.first().subtype)
infos.first().isEnabled = false
}
} else {
Toast.makeText(context, "Please enable keyboard first and then select language", Toast.LENGTH_SHORT).show()
this.isChecked = false
infos.first().isEnabled = false
}
}
Does it still happen in current 3.0 that doesn't have a 'Use System Languages' switch? I wasn't even aware there is a way to open the settings without enabling the keyboard. If you manage to do that, you will probably find many more ways to crash the app.
Yes so there certainly seems to be other smaller crashes associated with the settings activity before enabling keyboard. The language settings seemed to be a bigger one simply because of its popularity and usage.
I downloaded 3.0-beta3 apk and what happens is that when I click on the "Heliboard" name in keyboard system settings it simply takes me back to the "Welcome to Heliboard" screen and actually never opens the settings activity. In a way this is good since it's avoiding crashes, but at the same time if you look at other major keyboard players (Gboard, Swiftkey, etc.) they all provide the option for users to play around with their settings before the user even enables their keyboard.
if you look at other major keyboard players (Gboard, Swiftkey, etc.)
Well, I don't exactly have the same resources available as Google or Microsoft (multiple full-time employees vs 1 person doing things in their spare time). There are tons of "would be nice" things I don't do because I don't even have time for everything I consider important.
But I'm happy I unknowingly fixed potential crashes with the new settings 😃
on fresh installation only in private space under android 15 and activate the keyboard in android settings i got only a blank screen when i open the app directly until i activate the keyboard from another keyboard
then i got no keyboard but when i open the app directly the menu is shown and "language & layout" means the local language is setting but when i look into settings of "language & layout" no language is selected
after selecting one the keyboard is shown
but when the private space goes to locked state und i unlocked it the keyboard isnt shown until i open first the app directly
i can reproduce it after deleting data of the app
installation here was done yesterday from F-Droid
i wrote this here because i think it is related to "Languages & layouts" in the problem description of the first posting, if is not so then delete the comment or please move it to a new issue
Can you provide a log after you get the blank screen? (in About section of settings)
here it is, was create after deleting settings again -->
HeliBoard_log_2025-07-02_17-57-42_060013.txt
sorry, i think must do it again, this time app does not show blank screen, think because i switched keyboard before calling the app
HeliBoard_log_2025-07-02_17-57-42_061332.txt
after deleting settings and calling app directly -->
after switching to heliboard and go to "Language & …" -->
and it is further so that after enter lock screen of the profile i must call the app before i can use the keyboard