Closed2

No virtual method setStylusHandwritingEnabled in class Landroid/view/inputmethod/EditorInfo が発生する

slowhandslowhand

概要

いつの間にかテキスト入力をしようとフォーカスすると以下のエラーが出るようになっていました。その対応をした際のメモになります。

FATAL EXCEPTION: main
Process: com.xxxx.xxxx, PID: 9458
java.lang.NoSuchMethodError: No virtual method setStylusHandwritingEnabled(Z)V in class Landroid/view/inputmethod/EditorInfo; or its super classes (declaration of 'android.view.inputmethod.EditorInfo' appears in /system/framework/framework.jar!classes4.dex)
	at androidx.core.view.inputmethod.EditorInfoCompat$Api35Impl.setStylusHandwritingEnabled(EditorInfoCompat.java:606)
	at androidx.core.view.inputmethod.EditorInfoCompat.setStylusHandwritingEnabled(EditorInfoCompat.java:215)
	at androidx.compose.foundation.text.input.internal.EditorInfo_androidKt.update-pLxbY9I(EditorInfo.android.kt:168)
	at androidx.compose.foundation.text.input.internal.EditorInfo_androidKt.update-pLxbY9I$default(EditorInfo.android.kt:43)
	at androidx.compose.foundation.text.input.internal.LegacyTextInputMethodRequest.createInputConnection(LegacyPlatformTextInputServiceAdapter.android.kt:264)
	at androidx.compose.foundation.text.input.internal.LegacyTextInputMethodRequest.createInputConnection(LegacyPlatformTextInputServiceAdapter.android.kt:201)
	at androidx.compose.ui.platform.InputMethodSession.createInputConnection(AndroidPlatformTextInputSession.android.kt:143)
	at androidx.compose.ui.platform.AndroidPlatformTextInputSession.createInputConnection(AndroidPlatformTextInputSession.android.kt:107)
	at androidx.compose.ui.platform.AndroidComposeView.onCreateInputConnection(AndroidComposeView.android.kt:2184)
	at android.view.inputmethod.InputMethodManager.createInputConnection(InputMethodManager.java:4945)
	at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:3159)
	at android.view.inputmethod.InputMethodManager.startInputOnWindowFocusGainInternal(InputMethodManager.java:1018)
	at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:3471)
	at android.view.inputmethod.InputMethodManager.restartInput(InputMethodManager.java:3010)
	at androidx.compose.ui.text.input.InputMethodManagerImpl.restartInput(InputMethodManager.android.kt:76)
	at androidx.compose.ui.text.input.TextInputServiceAndroid.restartInputImmediately(TextInputServiceAndroid.android.kt:450)
	at androidx.compose.ui.text.input.TextInputServiceAndroid.processInputCommands(TextInputServiceAndroid.android.kt:343)
	at androidx.compose.ui.text.input.TextInputServiceAndroid.sendInputCommand$lambda$1(TextInputServiceAndroid.android.kt:264)
	at androidx.compose.ui.text.input.TextInputServiceAndroid.$r8$lambda$EPVR_TMFA5GOjs4tvuSSub8L5-M(Unknown Source:0)
	at androidx.compose.ui.text.input.TextInputServiceAndroid$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
	at androidx.compose.ui.text.input.TextInputServiceAndroid_androidKt.asExecutor$lambda$2$lambda$1(TextInputServiceAndroid.android.kt:569)
	at androidx.compose.ui.text.input.TextInputServiceAndroid_androidKt.$r8$lambda$nEtFUEU03rhWZ7PGABg9OjqaO2E(Unknown Source:0)
	at androidx.compose.ui.text.input.TextInputServiceAndroid_androidKt$$ExternalSyntheticLambda0.doFrame(D8$$SyntheticClass:0)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1404)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1415)
	at android.view.Choreographer.doCallbacks(Choreographer.java:1015)
	at android.view.Choreographer.doFrame(Choreographer.java:941)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1389)
	at android.os.Handler.handleCallback(Handler.java:959)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at android.os.Looper.loopOnce(Looper.java:232)
	at android.os.Looper.loop(Looper.java:317)
	at android.app.ActivityThread.main(ActivityThread.java:8628)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)

問題となっている setStylusHandwritingEnabled を調べてみると API Level 35から追加された新しいメソッドというのが分かる。

https://developer.android.com/reference/kotlin/android/view/inputmethod/EditorInfo#setstylushandwritingenabled

怪しそうな activity-compose1.9.3 だったので最新のに上げてみる

https://mvnrepository.com/artifact/androidx.activity/activity-compose

👆をみると 1.10.0-rc01 が最新らしい。

→ 結果ダメでした…

エラーログをよくみると android.coreview でおかしくなってそうなので、ここら辺を上げてみます。

core-ktx1.5.0 だったので最新の 1.16.0-alpha01 に上げてみと、、

https://mvnrepository.com/artifact/androidx.core/core-ktx

治りました!!!!

よくエラーログは見ないとダメですね 👀

このスクラップは2024/12/28にクローズされました