didi / VirtualAPK

A powerful and lightweight plugin framework for Android
Apache License 2.0
8.98k stars 1.52k forks source link

关于StripClassAndResTransform的一点疑问 #331

Open ghost opened 5 years ago

ghost commented 5 years ago
  1. build version(host和plugin配置完全一致)
    classPath 'com.didi.virtualapk:'
    compile 'com.didi.virtualapk:gradle:0.9.8.6.2-dev'
    gradle wrapper:  version 4.10.1
    build tool version: 28.0.3
  2. plugin virtual config
    virtualApk {
    packageId = 0x6f // 资源前缀.
    targetHost = '/Users/zl/code/temp/demo/host/app' // 宿主模块的文件路径,生成插件会检查依赖项,分析和排除与宿主APP的共同依赖.
    applyHostMapping = true //optional, default value: true.
    forceUseHostDependences = true
    }

    问题详细描述: 在host和plugin中,同时依赖相同版本的库,此处以compileOnly "net.changjinglu:webview:$rootProject.webview"为例,vaContext.stripDependencies中关于webviewService(内部有使用lambda表达式)仅包含以下几个相关类

    net/changjinglu/webview/process/WebViewService$1.class, net/changjinglu/webview/process/WebViewService$2.class, net/changjinglu/webview/process/WebViewService.class,

    而在transformInvocation.inputs.jarInputs中却包含以下几个相关类

    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$2.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$6.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$1.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$4.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$7.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$$Lambda$0.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$$Lambda$2.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$11.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$$Lambda$3.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$3.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$0.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$5.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$13.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$9.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$10.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$8.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$$Lambda$1.class
    [INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$12.class

    最终导致stripEntries.containsAll(jarEntries)为false,从而没有过滤该jar包

个人感觉是lambda表达式脱糖方式不一致导致的(顺便说一下,出现这种情况的都是java编写的代码,kotlin写的则没有这种情况),但是因为对这方面认知不太够,所以也没什么好的解决方式,不知道作者是否有相关思路,或解决方式,不胜感激。

asstea commented 4 years ago

我也遇到这个问题,最后有找到解决方式吗。

asstea commented 4 years ago
  1. build version(host和plugin配置完全一致)
classPath 'com.didi.virtualapk:'
compile 'com.didi.virtualapk:gradle:0.9.8.6.2-dev'
gradle wrapper:  version 4.10.1
build tool version: 28.0.3
  1. plugin virtual config
virtualApk {
   packageId = 0x6f // 资源前缀.
   targetHost = '/Users/zl/code/temp/demo/host/app' // 宿主模块的文件路径,生成插件会检查依赖项,分析和排除与宿主APP的共同依赖.
   applyHostMapping = true //optional, default value: true.
   forceUseHostDependences = true
}

问题详细描述: 在host和plugin中,同时依赖相同版本的库,此处以compileOnly "net.changjinglu:webview:$rootProject.webview"为例,vaContext.stripDependencies中关于webviewService(内部有使用lambda表达式)仅包含以下几个相关类

net/changjinglu/webview/process/WebViewService$1.class, net/changjinglu/webview/process/WebViewService$2.class, net/changjinglu/webview/process/WebViewService.class,

而在transformInvocation.inputs.jarInputs中却包含以下几个相关类

[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$2.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$6.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$1.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$4.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$7.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$$Lambda$0.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$$Lambda$2.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$11.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$$Lambda$3.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$3.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$0.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$5.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$13.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$9.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$10.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$8.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$$Lambda$1.class
[INFO][StripClassAndResTransform] not contains entry name = net/changjinglu/webview/process/WebViewService$2$$Lambda$12.class

最终导致stripEntries.containsAll(jarEntries)为false,从而没有过滤该jar包

个人感觉是lambda表达式脱糖方式不一致导致的(顺便说一下,出现这种情况的都是java编写的代码,kotlin写的则没有这种情况),但是因为对这方面认知不太够,所以也没什么好的解决方式,不知道作者是否有相关思路,或解决方式,不胜感激。

我也遇到这个问题,最后有找到解决方式吗?