美文网首页
Execution failed for task ':zz:t

Execution failed for task ':zz:t

作者: 蓝不蓝编程 | 来源:发表于2020-10-26 17:27 被阅读0次

    背景

    debug版本编译正常,release版本编译报错.

    编译报错日志

    Warning: can't write resource [META-INF/businessframe_release.kotlin_module] (Duplicate zip entry [6.jar:META-INF/businessframe_release.kotlin_module])
    Warning: can't write resource [META-INF/core_release.kotlin_module] (Duplicate zip entry [7.jar:META-INF/core_release.kotlin_module])
      Copying resources from program jar [/Users/jerry/projects/xx/yy/zz/build/intermediates/transforms/__ReplaceSuperClass__/release/7.jar]
      Copying resources from program jar [/Users/jerry/projects/xx/yy/zz/build/intermediates/transforms/__ReplaceSuperClass__/release/8.jar]
    Warning: Exception while processing task java.io.IOException: Can't write [/Users/jerry/projects/xx/yy/zz/build/intermediates/transforms/proguard/release/0.jar] (Can't read [/Users/jerry/projects/xx/yy/zz/build/intermediates/transforms/__ReplaceSuperClass__/release/8.jar] (Duplicate zip entry [8.jar:com/xxx/ActivityExtKt.class]))
    Thread(Tasks limiter_2): destruction
    Warning: can't write resource [META-INF/olddriver_release.kotlin_module] (Duplicate zip entry [8.jar:META-INF/olddriver_release.kotlin_module])
    :zz:transformClassesAndResourcesWithProguardForRelease FAILED
    247 actionable tasks: 37 executed, 21 from cache, 189 up-to-date
    apkFile==>/Users/jerry/projects/xx/yy/zz/build/outputs/apk/release/xx_1.9.0.apk
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':zz:transformClassesAndResourcesWithProguardForRelease'.
    > Job failed, see logs for details
    
    * 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 https://help.gradle.org
    
    BUILD FAILED in 53s
    {"errcode":0,"errmsg":"ok"}
    5:13:27 PM: Task execution finished 'phInstallPluginRelease'.
    

    分析

    具体问题在报错信息中并不明显,没有出现明显的Error信息,只有一堆Warning.
    关键点在倒数第二行的Warning中:
    Warning: Exception while processing task java.io.IOException: Can't write [/Users/jerry/projects/xx/yy/zz/build/intermediates/transforms/proguard/release/0.jar] (Can't read [/Users/jerry/projects/xx/yy/zz/build/intermediates/transforms/ReplaceSuperClass/release/8.jar] (Duplicate zip entry [8.jar:com/xxx/ActivityExtKt.class]))
    Thread(Tasks limiter_2): destruction

    提示:com/xxx/ActivityExtKt.class重复.
    按照这个类名去找,果然发现有两个模块出现了同名的类(包路径也相同).

    解决方案

    将重复的类的包名修改掉,避免重复.

    进一步思考

    后续如何快速排查此类问题.
    可以用./gradlew -s打印出报错详细信息,有助问题排查.
    打印样例:

    Caused by: java.io.IOException: Duplicate zip entry [8.jar:xx/ActivityExtKt.class]
            at proguard.io.JarWriter.getOutputStream(JarWriter.java:138)
            at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
            at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
            at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:92)
            at proguard.io.ClassRewriter.read(ClassRewriter.java:68)
            at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
            at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
            at proguard.io.JarReader.read(JarReader.java:65)
            at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65)
            at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53)
            at proguard.InputReader.readInput(InputReader.java:184)
            ... 12 more
    
    

    相关文章

      网友评论

          本文标题:Execution failed for task ':zz:t

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