美文网首页
Replugin 升级androidx 后 报找不到Activi

Replugin 升级androidx 后 报找不到Activi

作者: 勤劳的蚂蚁 | 来源:发表于2021-04-13 14:46 被阅读0次
     Unable to find explicit activity class {包名/..MoreEditActivity}; have you declared this activity in your AndroidManifest.xml
    
    场景是 Fragment 里面直接调用 startActicity(..)的方法,这个方法 replugin 没有拦截 成功,不能替换坑位,将startActicity(..)改为 getActivity().startActicity(..)后,报错消失,坑位替换成功。
    
    疑问: 为什么非androidx 版本没有这问题?
    看代码差不多,可能就是replugin 不支持androidx ,没有对androidx 兼容导致的问题。
    fragment 非androidx:
    
        FragmentHostCallback(Activity activity, Context context, Handler handler,
                int windowAnimations) {
            mActivity = activity;
            mContext = context;
            mHandler = handler;
            mWindowAnimations = windowAnimations;
        }
    
    androidx 版本:
        FragmentHostCallback(@Nullable Activity activity, @NonNull Context context,
                @NonNull Handler handler, int windowAnimations) {
            mActivity = activity;
            mContext = Preconditions.checkNotNull(context, "context == null");
            mHandler = Preconditions.checkNotNull(handler, "handler == null");
            mWindowAnimations = windowAnimations;
        }
    
    
    
     public void onStartActivityFromFragment(
                @NonNull Fragment fragment, @SuppressLint("UnknownNullness") Intent intent,
                int requestCode, @Nullable Bundle options) {
            if (requestCode != -1) {
                throw new IllegalStateException(
                        "Starting activity with a requestCode requires a FragmentActivity host");
            }
            mContext.startActivity(intent);
        }
    
    

    相关文章

      网友评论

          本文标题:Replugin 升级androidx 后 报找不到Activi

          本文链接:https://www.haomeiwen.com/subject/xdfclltx.html