穿山甲SDK编译出现java.util.zip.ZipException: zip file is empty问题解决

198 阅读4分钟

一、背景

线上穿山甲直播sdk 2.7.0 存在大量卡顿,ANR,和闪退问题,新版本将穿山甲SDK升级为2.9.0:

implementation ('com.pangle.cn:pangrowth-sdk:2.9.0.0'){
// exclude group: 'com.pangle.cn', module: 'pangrowth-dpsdk'
exclude group: 'com.pangle.cn', module: 'pangrowth-novel-sdk'
exclude group: 'com.pangle.cn', module: 'pangrowth-game-sdk'
exclude group: 'com.pangle.cn', module: 'pangrowth-luckycat-sdk'
exclude group: 'com.pangle.cn', module: 'pangrowth-reward-sdk'
exclude group: 'com.android.support'
}

编译出现:

:app:compileZroTest64DebugJavaWithJavac spend 19982ms
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)

......

Dilutions jarName:com.google.guava:guava:23.0-android; /Users/ice/MeiyouCode/PeriodProjectRelease/SeeyouClient/app/build/intermediates/transforms/ajx/zroTest64/debug/259.jar
Dilutions jarName:android.local.jars:classes.jar:003d3a7f4777b886d331589f2f281cc3287d1a9a; /Users/ice/MeiyouCode/PeriodProjectRelease/SeeyouClient/app/build/intermediates/transforms/ajx/zroTest64/debug/260.jar
Dilutions jarName:com.alibaba.baichuan.sdk:alibctriver:5.0.0.22; /Users/ice/MeiyouCode/PeriodProjectRelease/SeeyouClient/app/build/intermediates/transforms/ajx/zroTest64/debug/261.jar
Dilutions jarName:exclude; /Users/ice/MeiyouCode/PeriodProjectRelease/SeeyouClient/app/build/intermediates/transforms/ajx/zroTest64/debug/262.jar
Dilutions jarName:include; /Users/ice/MeiyouCode/PeriodProjectRelease/SeeyouClient/app/build/intermediates/transforms/ajx/zroTest64/debug/263.jar
:app:transformClassesWithDilutions-pluginForZroTest64Debug spend 26960ms

      00:27.89   :app:compileZroTest64DebugJavaWithJavac
00:26.96   :app:transformClassesWithDilutions-pluginForZroTest64Debug
00:23.14   :app:compileZroTest64DebugKotlin
00:18.55   :app:kaptZroTest64DebugKotlin
00:16.60   :app:transformClassesWithAjxForZroTest64Debug
00:16.09   :app:kaptGenerateStubsZroTest64DebugKotlin
00:13.73   :app:preZroTest64DebugBuild
00:13.21   :app:transformNativeLibsWithMergeJniLibsForZroTest64Debug
00:12.91   :app:processZroTest64DebugResources
00:12.86   :app:mergeZroTest64DebugResources
00:05.42   :app:clean
00:02.47   :app:processZroTest64DebugManifest
00:00.70   :app:mergeZroTest64DebugAssets
00:00.37   :app:compileZroTest64DebugRenderscript
00:00.27   :app:checkZroTest64DebugDuplicateClasses
00:00.10   :app:javaPreCompileZroTest64Debug
00:00.05   :app:createZroTest64DebugCompatibleScreenManifests

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformClassesWithDilutions-pluginForZroTest64Debug'.

java.util.zip.ZipException: zip file is empty

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at help.gradle.org

BUILD FAILED in 3m 8s
27 actionable tasks: 14 executed, 12 from cache, 1 up-to-date
[ice@icedeMacBook-Pro SeeyouClient (release=)]$ 

二、分析和解决

1、怀疑对方SDK问题,如 kotlin,androidx,java版本是否有变更,对方称只是正常的改动,没有编译相关的改造;

2、怀疑 Dilution插件

看编译堆栈信息,是在dilution插件在处理过程中出现问题,导致编译无法进行;

初步怀疑是Dilution插件问题,于是针对Dilution插件开放exclude拓展,将穿山甲SDK,都exclude掉,

发现问题依旧;

3、怀疑Aspect插件问题;

移除aspect插件,编译正常;

启用aspect插件,exclue com.bytedance相关的包,发现无用

4、分析依赖:

   2.7.0版本分析依赖如下:

--- com.pangle.cn:pangrowth-sdk:2.7.0.1
|              +--- com.pangle.cn:partner-luckycat-api-sdk:2.7.0.0
|              |    --- com.bytedance.applog:RangersAppLog-Lite-cn:6.9.6
|              |         +--- com.bytedance.frameworks:encryptor:0.0.9-rc.2-private
|              |         --- com.bytedance.mpaas:if_encryptor:1.0.0-rc.5
|              +--- com.bytedance.applog:RangersAppLog-Lite-cn:6.9.6 (*)
|              --- com.pangle.cn:pangrowth-dpsdk:3.8.0.1
|                   --- com.pangle.cn:partner-live-sdk:2.0.5.0-tob-154732232

   2.9.0版本分析依赖如下:

   --- com.pangle.cn:pangrowth-sdk:2.7.0.1 -> 2.9.0.0
|              +--- com.pangle.cn:partner-luckycat-api-sdk:2.9.0.0
|              |    --- com.bytedance.applog:RangersAppLog-Lite-cn:6.9.6
|              |         +--- com.bytedance.frameworks:encryptor:0.0.9-rc.2-private
|              |         --- com.bytedance.mpaas:if_encryptor:1.0.0-rc.5
|              +--- com.bytedance.applog:RangersAppLog-Lite-cn:6.9.6 (*)
|              --- com.pangle.cn:pangrowth-dpsdk:4.0.0.0
|                   --- com.pangle.cn:partner-live-sdk:2.0.6.0-tob-168897373

从以上两个分析可以看出,此SDK只有
com.pangle.cn:partner-luckycat-api-sdk:2.9.0.0

 com.pangle.cn:pangrowth-dpsdk:4.0.0.0

 com.pangle.cn:partner-live-sdk:2.0.6.0-tob-168897373

三个库进行了升级,

可以断点是这三个库有什么问题,导致aspect插件插桩异常,然后导致了编译失败;

于是一个一个查看,发现这个库的包名并不是com.bytedance或者com.byte开头,可能里边的代码和aspect不兼容,于是,将com.bytedance,com.byte,com.pandora和com.ss exclude掉,重新进行编译,发现问题依旧;

 于是将两个依赖分析使用Beyond Compare对比,发现除了sdk的变更外,还有一个库:org.aspectj:aspectjrt:1.8.13被升级穿山甲升级为了org.aspectj:aspectjrt:1.9.5

--- com.pangle.cn:pangrowth-dpsdk:4.0.0.0
|                   +--- com.pangle.cn:adclog:0.0.0.4
|                   |    --- com.bytedance.frameworks.baselib:utility:2.0.13
|                   +--- com.pangle.cn:partner-live-sdk:2.0.6.0-tob-168897373
|                   +--- com.bytedance.applog:RangersAppLog-Lite-cn:6.9.6 ()
|                   +--- com.android.support.constraint:constraint-layout:1.1.2 (
)
|                   +--- android.arch.lifecycle:extensions:1.1.1
|                   |    +--- android.arch.lifecycle:runtime:1.1.1 ()
|                   |    +--- android.arch.core:common:1.1.1 (
)
|                   |    +--- android.arch.core:runtime:1.1.1
|                   |    |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|                   |    |    --- android.arch.core:common:1.1.1 ()
|                   |    +--- com.android.support:support-fragment:26.1.0 (
)
|                   |    +--- android.arch.lifecycle:common:1.1.1 ()
|                   |    +--- android.arch.lifecycle:livedata:1.1.1
|                   |    |    +--- android.arch.core:runtime:1.1.1 (
)
|                   |    |    +--- android.arch.lifecycle:livedata-core:1.1.1
|                   |    |    |    +--- android.arch.lifecycle:common:1.1.1 ()
|                   |    |    |    +--- android.arch.core:common:1.1.1 (
)
|                   |    |    |    --- android.arch.core:runtime:1.1.1 ()
|                   |    |    --- android.arch.core:common:1.1.1 (
)
|                   |    --- android.arch.lifecycle:viewmodel:1.1.1
|                   |         --- com.android.support:support-annotations:26.1.0 -> 28.0.0
|                   +--- com.pangle.cn:nativekv:2.0.0
|                   +--- org.aspectj:aspectjrt:1.9.5
|                   +--- com.volcengine:apm_insight_sdk:1.1.5
|                   |    +--- com.volcengine:apm_insight_applog:0.0.8-rc.9
|                   |    |    +--- com.bytedance.frameworks:encryptor:0.0.9-rc.2-private
|                   |    |    +--- com.bytedance.mpaas:if_encryptor:1.0.0-rc.5
|                   |    |    +--- com.bytedance.frameworks.baselib:utility:2.0.13
|                   |    |    --- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61 -> 1.3.72 ()
|                   |    --- com.volcengine:apm_insight_crash:1.4.4
|                   |         +--- com.bytedance.frameworks:encryptor:0.0.9-rc.2-private
|                   |         --- com.volcengine:apm_insight_applog:0.0.8-rc.8 -> 0.0.8-rc.9 (
)
|                   --- com.volcengine:apm_insight_crash:1.4.4 (*)

对比了旧版本的穿山甲直播SDK如下:

--- com.pangle.cn:pangrowth-dpsdk:3.8.0.1
|                   +--- com.bytedance.applog:RangersAppLog-Lite-cn:6.9.6 ()
|                   +--- com.android.support.constraint:constraint-layout:1.1.2 (
)
|                   +--- android.arch.lifecycle:extensions:1.1.1
|                   |    +--- android.arch.lifecycle:runtime:1.1.1 ()
|                   |    +--- android.arch.core:common:1.1.1 (
)
|                   |    +--- android.arch.core:runtime:1.1.1
|                   |    |    +--- com.android.support:support-annotations:26.1.0 -> 27.1.1
|                   |    |    --- android.arch.core:common:1.1.1 ()
|                   |    +--- com.android.support:support-fragment:26.1.0 (
)
|                   |    +--- android.arch.lifecycle:common:1.1.1 ()
|                   |    +--- android.arch.lifecycle:livedata:1.1.1
|                   |    |    +--- android.arch.core:runtime:1.1.1 (
)
|                   |    |    +--- android.arch.lifecycle:livedata-core:1.1.1
|                   |    |    |    +--- android.arch.lifecycle:common:1.1.1 ()
|                   |    |    |    +--- android.arch.core:common:1.1.1 (
)
|                   |    |    |    --- android.arch.core:runtime:1.1.1 ()
|                   |    |    --- android.arch.core:common:1.1.1 (
)
|                   |    --- android.arch.lifecycle:viewmodel:1.1.1
|                   |         --- com.android.support:support-annotations:26.1.0 -> 27.1.1
|                   +--- com.pangle.cn:partner-live-sdk:2.0.5.0-tob-154732232
|                   +--- com.volcengine:apm_insight_sdk:1.1.5
|                   |    +--- com.volcengine:apm_insight_applog:0.0.8-rc.9
|                   |    |    +--- com.bytedance.frameworks:encryptor:0.0.9-rc.2-private
|                   |    |    +--- com.bytedance.mpaas:if_encryptor:1.0.0-rc.5
|                   |    |    +--- com.bytedance.frameworks.baselib:utility:2.0.13
|                   |    |    --- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61 -> 1.3.72 ()
|                   |    --- com.volcengine:apm_insight_crash:1.4.4
|                   |         +--- com.bytedance.frameworks:encryptor:0.0.9-rc.2-private
|                   |         --- com.volcengine:apm_insight_applog:0.0.8-rc.8 -> 0.0.8-rc.9 (
)
|                   --- com.volcengine:apm_insight_crash:1.4.4 (*)

说明新版本新增了aspect 依赖:org.aspectj:aspectjrt,应该是对apm进行了改造,看起来应该是这个问题,反馈给对方更换SDK;

通过反编译工具查看,发现SDK内部有个这样的类:

大概率是这个问题引起的,对方已介入解决;