Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditText输入内容后,再次获取焦点输入,插件崩溃 #1001

Closed
userfuy opened this issue Apr 14, 2021 · 11 comments
Closed

EditText输入内容后,再次获取焦点输入,插件崩溃 #1001

userfuy opened this issue Apr 14, 2021 · 11 comments

Comments

@userfuy
Copy link

userfuy commented Apr 14, 2021

问题详细描述 Detailed description of the problem

EditText输入内容后,再次获取焦点输入,插件崩溃。
手机升级Android 10最新版本后,问题出现,升级前的Android 10系统无问题。

复现问题步骤 Steps to reproduce the problem

  1. EditText输入内容;
  2. 再次获取焦点输入,插件崩溃

其它重要信息 Other important information

replugin-host-lib/gradle Version:
rePlugin-plugin-lib/gradle Version:

Android API Version:
Android 手机型号&ROM(Phone model & ROM):

Logcat上下文 Logcat context

04-14 14:59:36.369 7935 7935 E CrashReporter:
04-14 14:59:36.379 7935 7935 E CrashReporter: [EXCEPTION]
04-14 14:59:36.389 7935 7935 E CrashReporter: Name: Resource ID #0x0
04-14 14:59:36.399 7935 7935 E CrashReporter: Reason: android.content.res.Resources$NotFoundException: Resource ID #0x0
04-14 14:59:36.419 7935 7935 E CrashReporter: Process ID: 7935
04-14 14:59:36.429 7935 7935 E CrashReporter: Thread: 7935 (main)
04-14 14:59:36.440 7935 7935 E CrashReporter: Call Stack 1: android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:404)
04-14 14:59:36.450 7935 7935 E CrashReporter: Call Stack 2: android.content.res.Resources.getDrawableForDensity(Resources.java:1004)
04-14 14:59:36.460 7935 7935 E CrashReporter: Call Stack 3: android.content.res.Resources.getDrawable(Resources.java:944)
04-14 14:59:36.470 7935 7935 E CrashReporter: Call Stack 4: library.d.getDrawable(Unknown Source:13)
04-14 14:59:36.480 7935 7935 E CrashReporter: Call Stack 5: android.content.Context.getDrawable(Context.java:687)
04-14 14:59:36.490 7935 7935 E CrashReporter: Call Stack 6: android.widget.TextView.getTextSelectHandle(TextView.java:3727)
04-14 14:59:36.500 7935 7935 E CrashReporter: Call Stack 7: android.widget.Editor.loadHandleDrawables(Editor.java:7792)
04-14 14:59:36.511 7935 7935 E CrashReporter: Call Stack 8: android.widget.Editor$InsertionPointCursorController.getHandle(Editor.java:7233)
04-14 14:59:36.521 7935 7935 E CrashReporter: Call Stack 9: android.widget.Editor$InsertionPointCursorController.show(Editor.java:7212)
04-14 14:59:36.531 7935 7935 E CrashReporter: Call Stack 10: android.widget.Editor.onTouchUpEvent(Editor.java:2623)
04-14 14:59:36.541 7935 7935 E CrashReporter: Call Stack 11: android.widget.TextView.onTouchEvent(TextView.java:11185)
04-14 14:59:36.551 7935 7935 E CrashReporter: Call Stack 12: android.view.View.dispatchTouchEvent(View.java:13665)
04-14 14:59:36.561 7935 7935 E CrashReporter: Call Stack 13: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3249)
04-14 14:59:36.571 7935 7935 E CrashReporter: Call Stack 14: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2938)
04-14 14:59:36.582 7935 7935 E CrashReporter: Call Stack 15: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3249)
04-14 14:59:36.592 7935 7935 E CrashReporter: Call Stack 16: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2938)
04-14 14:59:36.602 7935 7935 E CrashReporter: Call Stack 17: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3249)
04-14 14:59:36.612 7935 7935 E CrashReporter: Call Stack 18: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2938)
04-14 14:59:36.623 7935 7935 E CrashReporter: Call Stack 19: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3249)
04-14 14:59:36.633 7935 7935 E CrashReporter: Call Stack 20: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2938)

@chwnFlyPig
Copy link

是华为的鸿蒙手机吗?我这边也遇到了这个问题。你先把PluginResource的逻辑去掉试一下,就是插件基类里去掉getResources方法里的使用PluginResource的逻辑。

@AdminQQZ
Copy link

拒绝鸿蒙,从你开始

@sadikelong
Copy link

继承EditText重写一下崩溃的方法就行了,设置正确的上下文即可。
android.widget.TextView.getTextSelectHandle(TextView.java:3727)这个方法是android10的一本版本引入的,之前没有。
很小的问题。

@userfuy
Copy link
Author

userfuy commented Sep 17, 2021

修改方案:
hanschencoder@f1be6db

@userfuy userfuy closed this as completed Sep 17, 2021
@lioilwin
Copy link

@userfuy @shensky711 非常感谢,很好解决了这个问题。

@shadow520
Copy link

是华为的鸿蒙手机吗?我这边也遇到了这个问题。你先把PluginResource的逻辑去掉试一下,就是插件基类里去掉getResources方法里的使用PluginResource的逻辑。

你好,请问这个怎么修改插件基类呢?

@shadow520
Copy link

@userfuy @shensky711 非常感谢,很好解决了这个问题。

你好,请问你这个问题是怎么解决的呢,我发现这个修改的代码并没有合入

@shadow520
Copy link

修改方案: hanschencoder@f1be6db

你好,这个请求没有合并,怎么办呢?

@hanschencoder
Copy link

修改方案: hanschencoder@f1be6db

你好,这个请求没有合并,怎么办呢?

自己编一个~这项目估计也不维护了

@userfuy
Copy link
Author

userfuy commented May 28, 2022

不修改Replugin的解决方案:
1、Application中注册Activity监听registerActivityLifecycleCallbacks(this);
2、监听页面创建前修改Bundle内容,删除恢复fragment信息,防止页面重建时崩溃
@OverRide
public void onActivityPreCreated(@nonnull Activity activity, @nullable Bundle savedInstanceState) {
if (null != savedInstanceState) {
savedInstanceState.setClassLoader(activity.getClassLoader());
removeFragmentsState(savedInstanceState);
}
}

protected void removeFragmentsState(@Nullable Bundle bundle) {
    if (bundle == null) {
        return;
    }
    bundle.remove("android:support:fragments");
    bundle.remove("android:fragments");
    Set<String> keySet = bundle.keySet();
    for (String key : keySet) {
        Object next = bundle.get(key);
        if (next != null && next instanceof Bundle) {
            removeFragmentsState((Bundle) next);
        }
    }
}

@shadow520
Copy link

shadow520 commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants