Skip to content

Commit 6664d91

Browse files
committed
更新ReadMe
1 parent 1ffa013 commit 6664d91

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

PluginCore/src/com/plugin/core/PluginCreator.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static Resources createPluginResource(Application application, String abs
7777
}
7878

7979
private static String[] buildAssetPath(boolean isStandalone, String app, String plugin, String[] dependencies) {
80-
String[] assetPaths = new String[isStandalone ? 1 : 2];
80+
String[] assetPaths = new String[isStandalone ? 1 : (2 + (dependencies==null?0:dependencies.length))];
8181

8282
// if (!isStandalone) {
8383
// // 不可更改顺序否则不能兼容4.x
@@ -96,12 +96,23 @@ private static String[] buildAssetPath(boolean isStandalone, String app, String
9696
// }
9797

9898

99-
//若需支持插件间资源依赖,这里需要遍历添加dependencies
100-
10199
if (!isStandalone) {
102100
// 不可更改顺序否则不能兼容4.x,如华为P7-Android4.4.2
103101
assetPaths[0] = plugin;
104-
assetPaths[1] = app;
102+
if (dependencies != null) {
103+
//插件间资源依赖,这里需要遍历添加dependencies
104+
//这里只处理1级依赖,若被依赖的插件又依赖其他插件,这里不做支持
105+
//插件依赖插件,如果被依赖的插件中包含资源文件,则需要在所有的插件中提供public.xml文件来分组资源id
106+
for(int i = 0; i < dependencies.length; i++) {
107+
PluginDescriptor pd = PluginLoader.getPluginDescriptorByPluginId(dependencies[i]);
108+
if (pd != null) {
109+
assetPaths[1+ i] = pd.getInstalledPath();
110+
} else {
111+
assetPaths[1+ i] = "";
112+
}
113+
}
114+
}
115+
assetPaths[assetPaths.length -1] = app;
105116
LogUtil.d("create Plugin Resource from: ", assetPaths[0], assetPaths[1]);
106117
} else {
107118
assetPaths[0] = plugin;

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060

6161
因此需要提前通知系统,宿主需要在哪些cpu模式下运行。提前通知的方式即内置占位so。
6262

63+
4、插件间依赖时,如果被依赖的插件中包含资源文件,则依赖深度只支持1级、且需要在所有插件中增加public.xml配置以分组资源id。被依赖的插件中不包含资源时可支持多级依赖,插件中无需配置public.xml
6364

6465
目录结构说明:
6566

@@ -73,7 +74,7 @@
7374

7475
5、PluginHelloWorld是用来测试的独立插件Demo工程。
7576

76-
6、PluginBase是用来测试的被PluginTest插件依赖的插件Demo工程(插件间依赖)。
77+
6、PluginBase是用来测试的被PluginTest插件依赖的插件Demo工程(插件间依赖),此插件不包含资源
7778

7879
demo安装说明:
7980

0 commit comments

Comments
 (0)