多个插件包应该如何接入

Đang mở
#1,402 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
22/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
android, java
Lĩnh vực
backend, mobile

Hướng nghiên cứu

Start by tracing how each plugin package is installed and how its UUID and partKey are associated when the host loads it; the issue names PluginHelper, the manager's getPluginProcessServiceName implementation, and the pluginApks Gradle configuration. Reproduce loading plugin-app and plugin-app2 in sequence, then inspect the lookup that reports UUID 952B6898-E689-4976-9711-91052AABCC3D with partKey plugin-app2. Done means the cause of the cross-plugin lookup is identified and a working multi-plugin integration example is provided.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

目前已经在宿主中接入了一个plugin-app可以正常从宿主跳转到插件,然后准备扩展多个插件包;
1、新建了另外一个插件app工程plugin-app2,然后按照和plugin-app一样的接入流程接入框架,
2、修改plugin-app2工程根目录下的build.gradle,修改差异点为以下:

        pluginApks {
                    pluginApk1 {
                        businessName = 'plugin-app2'
                        partKey = 'plugin-app2'
                        buildTask = ':plugin-app2:assembleDebug'
                        apkPath = 'plugin-app2/build/outputs/apk/plugin/debug/plugin-app2-plugin-debug.apk'
                             hostWhiteList = ["com.tencent.shadow.sample.host.lib"]
                    }
                }

3、修改manager工程根据partKey返回对应的类名(这些类名已经在宿主中声明并注册)

   @Override
    protected String getPluginProcessServiceName(String partKey) {
      if (PLUGIN_APP_NAME.equals(partKey)){
            return "com.lph.plugin_host.plugin_manager.MainPluginProcessService";
        }else {
            return "com.lph.plugin_host.plugin_manager.MainPlugin2ProcessService";
        }
    }

4、最终编译plugin-app2 packageDebugPlugin 得到plugin-debug.zip。
5、因为plugin-app已经在宿主assets中放了plugin-debug.zip,plugin-app2 编译产物改名plugin-debug2.zip,同时在宿主的PluginHelper里面加载这两个zip

以上是我大致的集成步骤,因为公司网络限制,无法上传图片。

下面这个是从宿主点击触发插件包,加载的zip路径,partkey,uuid这些信息
plugin-debug.zip
installedPlugin:/data/user/0/com.lph.plugin_host/files/plugin-debug.zip,partKey:plugin-app,UUID:952B6898-E689-4976-9711-91052AABCC3D

plugin-debug2.zip
installedPlugin:/data/user/0/com.lph.plugin_host/files/plugin-debug2.zip,partKey:plugin-app2,UUID:DF1E82F7-D6C5-4EFA-B9BA-A5150CC5FAD2

打开plugin-debug2插件包,闪退
日志报错大概这个信息
uuid==952B6898-E689-4976-9711-91052AABCC3D partKey==plugin-app2 的Plugin找不到

我的疑问是,uuid==952B6898-E689-4976-9711-91052AABCC3D对应的插件应该是plugin-app,在plugin-app2肯定是找不到的,为什么框架会从另外一个插件的uuid去找,还是我这边在集成的时候哪里出错了,希望大佬能帮忙解答。

如果可以的话,希望可以提供一个多插件接入的示例代码,谢谢;

Ngôn ngữ chính
Java
Star
7.8k
Fork
1.3k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Tencent/Shadow

Tất cả issue của Tencent/Shadow

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.