osfans / trime

同文安卓輸入法平臺3.x/Android-rime/Rime Input Method Engine for Android
http://osfans.github.io/trime/
GNU General Public License v3.0
3.09k stars 372 forks source link

Android 10.0下无法使用输入法 #298

Closed monologconnor closed 5 years ago

monologconnor commented 5 years ago

机型为Pixel, 在安卓10.0下无法唤出输入法,且app大概率无响应

npwjim commented 5 years ago

機型 Pixel 3 升級至 Android 10 後無法使用輸入法,切換至 Trime 後會出現如下圖的錯誤訊息。 目前使用的輸入法版本為 3.1.2。 Screenshot_20190905-002136

wzyboy commented 5 years ago

以我粗浅的 Android 知识看了一下 adb logcat | grep rime 的输出。当在设置中启用 Trime 时,会每秒成白上千条地刷 /sdcard/rime/build/trime.yaml 不存在的错误,直到 ANR 被干掉:

09-20 17:12:36.798 13048 13048 I native  : I/auto_patch_config_plugin.cc:28 auto-patch trime:/__patch: trime.custom:/patch?
09-20 17:12:36.798 13048 13048 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:12:36.798 13048 13048 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:12:36.832 13048 13048 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:12:36.832 13048 13048 I native  : I/config_data.cc:65 loading config file '/sdcard/rime/trime.yaml'.
09-20 17:12:36.832 13048 13048 I native  : I/auto_patch_config_plugin.cc:28 auto-patch trime:/__patch: trime.custom:/patch?
09-20 17:12:36.833 13048 13048 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:12:36.833 13048 13048 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:12:36.843 13048 13048 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:12:36.843 13048 13048 I native  : I/config_data.cc:65 loading config file '/sdcard/rime/trime.yaml'.
09-20 17:12:36.844 13048 13048 I native  : I/auto_patch_config_plugin.cc:28 auto-patch trime:/__patch: trime.custom:/patch?
09-20 17:12:36.846 13048 13048 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:12:36.846 13048 13048 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:12:36.855 13048 13048 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:12:36.855 13048 13048 I native  : I/config_data.cc:65 loading config file '/sdcard/rime/trime.yaml'.
09-20 17:12:36.855  1350  1380 E ActivityManager: ANR in com.osfans.trime
09-20 17:12:36.855  1350  1380 E ActivityManager: Reason: executing service com.osfans.trime/.Trime
09-20 17:12:36.855 13048 13048 I native  : I/auto_patch_config_plugin.cc:28 auto-patch trime:/__patch: trime.custom:/patch?
09-20 17:12:36.855 13048 13048 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:12:36.855 13048 13048 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:12:36.858  1350  1380 I ActivityManager: Killing 13048:com.osfans.trime/u0a235 (adj 0): bg anr

我在 adb shell 里看了下, /sdcard/rime/build/trime.yaml 的确不存在。于是我删除了 build 目录,试图让它重新创建,但是我得到了这样的刷屏:

09-20 17:14:39.557 13439 13439 E native  : E/deployment_tasks.cc:258 error creating directory '/sdcard/rime/build'.
09-20 17:14:39.557 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.558 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.580 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.580 13439 13439 E native  : E/deployment_tasks.cc:258 error creating directory '/sdcard/rime/build'.
09-20 17:14:39.581 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.581 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.602 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.603 13439 13439 E native  : E/deployment_tasks.cc:258 error creating directory '/sdcard/rime/build'.
09-20 17:14:39.603 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.603 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.626 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.626 13439 13439 E native  : E/deployment_tasks.cc:258 error creating directory '/sdcard/rime/build'.
09-20 17:14:39.627 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.627 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.732 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.733 13439 13439 E native  : E/deployment_tasks.cc:258 error creating directory '/sdcard/rime/build'.
09-20 17:14:39.733 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.733 13439 13439 W native  : W/config_data.cc:62 nonexistent config file '/sdcard/rime/build/trime.yaml'.
09-20 17:14:39.761  1350  1380 E ActivityManager: ANR in com.osfans.trime
09-20 17:14:39.761  1350  1380 E ActivityManager: Reason: executing service com.osfans.trime/.Trime
09-20 17:14:39.762  1350  1380 I ActivityManager: Killing 13439:com.osfans.trime/u0a235 (adj 0): bg anr

我看了下, build 目录没有被重建,并且由于应用无响应,我也无法点那个 Deploy 按钮。

是不是因为 Android Q 的 Scoped Storage 特性导致 Trime 无法读取/创建 /sdcard 上的文件或目录? https://developer.android.com/training/data-storage/files/external-scoped

我的机器型号是 Google Pixel 3,未 root 的原厂系统。希望这些 logcat 输出对 @osfans 的排错有帮助。如果需要我帮忙调试的,我很乐意帮忙!

wzyboy commented 5 years ago

/sdcard/rime 改名成 /sdcard/rime.bak ,并且清除 Trime 的 data + cache 之后再打开应用,会有新的存储权限获取请求,同意之后,直接点 Deploy,应用闪退,同时在 logcat 中可观察到如下 NPE:

09-20 17:24:27.160 14613 14662 E Pref    : Deploy Exceptionjava.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.osfans.trime.Config.getResDataDir(java.lang.String)' on a null object reference
09-20 17:24:27.169  1350  1619 W InputDispatcher: channel '8f36b3a com.osfans.trime/com.osfans.trime.Pref (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
09-20 17:24:27.169  1350  1619 E InputDispatcher: channel '8f36b3a com.osfans.trime/com.osfans.trime.Pref (server)' ~ Channel is unrecoverably broken and will be disposed!
09-20 17:24:27.171  1350  1619 W InputDispatcher: channel '74f4a27 com.osfans.trime/com.osfans.trime.Pref (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
09-20 17:24:27.171  1350  1619 E InputDispatcher: channel '74f4a27 com.osfans.trime/com.osfans.trime.Pref (server)' ~ Channel is unrecoverably broken and will be disposed!
09-20 17:24:27.172  1350  7628 I ActivityManager: Process com.osfans.trime (pid 14613) has died: fore TOP
09-20 17:24:27.172  1350  3334 I WindowManager: WIN DEATH: Window{74f4a27 u0 com.osfans.trime/com.osfans.trime.Pref}
09-20 17:24:27.172  1350  3334 W InputDispatcher: Attempted to unregister already unregistered input channel '74f4a27 com.osfans.trime/com.osfans.trime.Pref (server)'
09-20 17:24:27.173  1350  4125 I WindowManager: WIN DEATH: Window{8f36b3a u0 com.osfans.trime/com.osfans.trime.Pref}
09-20 17:24:27.173  1350  4125 W InputDispatcher: Attempted to unregister already unregistered input channel '8f36b3a com.osfans.trime/com.osfans.trime.Pref (server)'
09-20 17:24:27.175  1350  7628 W ActivityTaskManager: Force removing ActivityRecord{654572d u0 com.osfans.trime/.Pref t18485}: app died, no saved state

启用并切换到 Trime,则应用卡死,同时在 logcat 中重复如下输出直到 ANR:

09-20 17:27:43.691 15005 15005 E Config  : /sdcard/rime/bopomofo_tw.schema.yaml: open failed: ENOENT (No such file or directory)
09-20 17:27:43.693 15005 15005 E Config  : /sdcard/rime/default.yaml: open failed: ENOENT (No such file or directory)
09-20 17:27:43.695 15005 15005 E Config  : /sdcard/rime/essay.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.697 15005 15005 E Config  : /sdcard/rime/luna_pinyin.dict.yaml: open failed: ENOENT (No such file or directory)
09-20 17:27:43.699 15005 15005 E Config  : /sdcard/rime/luna_pinyin.schema.yaml: open failed: ENOENT (No such file or directory)
09-20 17:27:43.700 15005 15005 E Config  : /sdcard/rime/luna_pinyin_simp.schema.yaml: open failed: ENOENT (No such file or directory)
09-20 17:27:43.703 15005 15005 E Config  : /sdcard/rime/opencc/HKVariants.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.704 15005 15005 E Config  : /sdcard/rime/opencc/HKVariantsPhrases.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.706 15005 15005 E Config  : /sdcard/rime/opencc/HKVariantsRev.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.707 15005 15005 E Config  : /sdcard/rime/opencc/HKVariantsRevPhrases.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.708 15005 15005 E Config  : /sdcard/rime/opencc/JPVariants.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.710 15005 15005 E Config  : /sdcard/rime/opencc/STCharacters.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.711 15005 15005 E Config  : /sdcard/rime/opencc/STPhrases.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.712 15005 15005 E Config  : /sdcard/rime/opencc/TSCharacters.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.713 15005 15005 E Config  : /sdcard/rime/opencc/TSPhrases.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.714 15005 15005 E Config  : /sdcard/rime/opencc/TWPhrases.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.715 15005 15005 E Config  : /sdcard/rime/opencc/TWPhrasesRev.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.716 15005 15005 E Config  : /sdcard/rime/opencc/TWVariants.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.717 15005 15005 E Config  : /sdcard/rime/opencc/TWVariantsRev.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.718 15005 15005 E Config  : /sdcard/rime/opencc/TWVariantsRevPhrases.txt: open failed: ENOENT (No such file or directory)
09-20 17:27:43.719 15005 15005 E Config  : /sdcard/rime/opencc/hk2s.json: open failed: ENOENT (No such file or directory)
09-20 17:27:43.719 15005 15005 E Config  : /sdcard/rime/opencc/s2hk.json: open failed: ENOENT (No such file or directory)
09-20 17:27:43.720 15005 15005 E Config  : /sdcard/rime/opencc/s2t.json: open failed: ENOENT (No such file or directory)
09-20 17:27:43.721 15005 15005 E Config  : /sdcard/rime/opencc/s2tw.json: open failed: ENOENT (No such file or directory)
09-20 17:27:43.722 15005 15005 E Config  : /sdcard/rime/opencc/s2twp.json: open failed: ENOENT (No such file or directory)
09-20 17:27:43.723 15005 15005 E Config  : /sdcard/rime/opencc/t2hk.json: open failed: ENOENT (No such file or directory)
09-20 17:27:43.724 15005 15005 E Config  : /sdcard/rime/opencc/t2s.json: open failed: ENOENT (No such file or directory)
09-20 17:27:43.724 15005 15005 E Config  : /sdcard/rime/opencc/t2tw.json: open failed: ENOENT (No such file or directory)
09-20 17:27:43.725 15005 15005 E Config  : /sdcard/rime/opencc/tw2s.json: open failed: ENOENT (No such file or directory)
09-20 17:27:43.726 15005 15005 E Config  : /sdcard/rime/opencc/tw2sp.json: open failed: ENOENT (No such file or directory)
09-20 17:27:43.727 15005 15005 E Config  : /sdcard/rime/qinghong.trime.yaml: open failed: ENOENT (No such file or directory)
09-20 17:27:43.728 15005 15005 E Config  : /sdcard/rime/sougou.trime.yaml: open failed: ENOENT (No such file or directory)
09-20 17:27:43.729 15005 15005 E Config  : /sdcard/rime/symbols.yaml: open failed: ENOENT (No such file or directory)
09-20 17:27:43.730 15005 15005 E Config  : /sdcard/rime/terra_pinyin.dict.yaml: open failed: ENOENT (No such file or directory)
09-20 17:27:43.730 15005 15005 E Config  : /sdcard/rime/tongwenfeng.trime.yaml: open failed: ENOENT (No such file or directory)
09-20 17:27:43.731 15005 15005 E Config  : /sdcard/rime/trime.yaml: open failed: ENOENT (No such file or directory)
09-20 17:27:45.073  1350  1380 E ActivityManager: ANR in com.osfans.trime
09-20 17:27:45.073  1350  1380 E ActivityManager: Reason: executing service com.osfans.trime/.Trime
09-20 17:27:45.073  1350  1380 E ActivityManager:   2.2% 15005/com.osfans.trime: 1.5% user + 0.7% kernel / faults: 1279 minor

在以上两步操作之后, /sdcard/rime 依然没有被创建。

看起来是 Trime 在 Android Q 里完全失去了对用户存储的读写能力……

wzyboy commented 5 years ago

我发现 @osfans 已经修复这个问题了。

我拿这个 commit 编了一个 debug apk 试了下,终于能运行了!有需要的可以下载试下。注意由于是 debug key,签名不一致,所以需要把 Play Store 的版本先卸载才能安装。

trime-730a0796a7ed3b3e9a28af4764bca9e5b0aa1f26.apk.zip

Bambooin commented 5 years ago

https://github.com/osfans/trime/blob/gh-pages/release/app-release.apk

请试试最新的版本,验证一下是否可以在Q运行。如果可以请告诉其他等待 Q版本的 Rimer。

monologconnor commented 5 years ago

这个release已经可以在Q运行了 如果大家都可以运行或者没有别的相关问题的话我就把这个issue关了吧 感谢

wzyboy commented 5 years ago

感谢 Bambooin 的版本,我测试了下可以在 Q 正常运行。大家不用装我的 debug key 版本了,他的版本是 release key 的,未来可以直接收到 Play Store 的更新。

npwjim commented 5 years ago

測試了 Bambooin release 的版本已可以在 Android 10 正常使用,感謝 Bambooin 與 wzyboy 的協助。

tangweijr commented 5 years ago

android Q已经可以运行,感谢