任务':app:transformClassesWithDesugarForRelease'的离子执行失败

Posted

技术标签:

【中文标题】任务\':app:transformClassesWithDesugarForRelease\'的离子执行失败【英文标题】:Ionic Execution failed for task ':app:transformClassesWithDesugarForRelease'任务':app:transformClassesWithDesugarForRelease'的离子执行失败 【发布时间】:2019-04-14 19:06:54 【问题描述】:

当我尝试在笔记本电脑和 Ionic 的 Pro 仪表板中构建 android 时出现此错误。

[04:27:55]: ▸ FAILURE: Build failed with an exception.
[04:27:55]: ▸ * What went wrong:
[04:27:55]: ▸ Execution failed for task ':app:transformClassesWithDesugarForRelease'.
[04:27:55]: ▸ > com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.google.devtools.build.android.desugar.Desugar with arguments --input /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/43.jar --output /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/desugar/release/45.jar --input /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/49.jar --output /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/desugar/release/51.jar --input /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/37.jar --output /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/desugar/release/39.jar --input /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/3.jar --output /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/desugar/release/5.jar --input /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/28.jar --output /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/desugar/release/30.jar --input /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/47.jar --output /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/desugar/release/49.jar --input /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/19.jar --output /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/desugar/release/21.jar --input /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/44.jar --output /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/desugar/release/46.jar --classpath_entry /builds/user/anonymous-social/platforms/android/CordovaLib/build/intermediates/intermediate-jars/release/classes.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/classes/release --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/0.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/1.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/2.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/3.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/4.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/5.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/6.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/7.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/8.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/9.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/10.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/11.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/12.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/13.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/14.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/15.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/16.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/17.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/18.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/19.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/20.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/21.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/22.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/23.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/24.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/25.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/26.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/27.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/28.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/29.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/30.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/31.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/32.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/33.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/34.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/35.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/36.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/37.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/38.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/39.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/40.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/41.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/42.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/43.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/44.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/45.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/46.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/47.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/48.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/49.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/50.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/51.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/52.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/53.jar --classpath_entry /builds/user/anonymous-social/platforms/android/app/build/intermediates/transforms/stackFramesFixer/release/54.jar --bootclasspath_entry /opt/android-sdk/platforms/android-27/android.jar --bootclasspath_entry /opt/android-sdk/platforms/android-27/optional/org.apache.http.legacy.jar --bootclasspath_entry /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/resources.jar --bootclasspath_entry /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar --bootclasspath_entry /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jsse.jar --bootclasspath_entry /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jce.jar --bootclasspath_entry /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/charsets.jar --min_sdk_version 19 --nodesugar_try_with_resources_if_needed --desugar_try_with_resources_omit_runtime_classes

对于整个构建细节,我制作了一个 pastebin:https://pastebin.com/QmJ6Tee3

我注意到如果我进入Platforms > android > project.properties,我的详细信息是:

target=android-27
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.gradle.include.1=cordova-android-firebase-gradle-release/bemochi-cordova-android-firebase-gradle-release.gradle
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.gradle.include.2=cordova-plugin-firebase/bemochi-build.gradle
cordova.system.library.2=com.google.gms:google-services:+
cordova.system.library.3=com.google.android.gms:play-services-tagmanager:+
cordova.system.library.4=com.google.firebase:firebase-core:+
cordova.system.library.5=com.google.firebase:firebase-messaging:+
cordova.system.library.6=com.google.firebase:firebase-crash:+
cordova.system.library.7=com.google.firebase:firebase-config:+
cordova.system.library.8=com.google.firebase:firebase-perf:+
cordova.system.library.9=com.google.android.gms:play-services-analytics:16.0.3
cordova.system.library.10=com.google.android.gms:play-services-location:15.+
cordova.system.library.11=com.android.support:support-v4:26.+
cordova.system.library.12=com.android.support:appcompat-v7:26.+
cordova.gradle.include.3=me.tonny.cordova.plugins.multidex/bemochi-build.gradle

我不确定我做错了什么。

我不确定这是否有帮助,但我的 build.gradle 有这个部分:

allprojects 
    repositories 
        jcenter()
        maven 
            url "https://maven.google.com"
        
    
    //This replaces project.properties w.r.t. build settings
    project.ext 
      defaultBuildToolsVersion="27.0.1" //String
      defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
      defaultTargetSdkVersion=27 //Integer - We ALWAYS target the latest by default
      defaultCompileSdkVersion=27 //Integer - We ALWAYS compile with the latest by default
    

我还读到,当您遇到此问题时,您可以使用 2 个插件来修复它,但它们显然不适合我 (config.xml):

<plugin name="cordova-android-support-gradle-release" spec="1.4.7">
    <variable name="ANDROID_SUPPORT_VERSION" value="15.+" />
</plugin>
<plugin name="cordova-android-firebase-gradle-release" spec="^2.0.0">
    <variable name="FIREBASE_VERSION" value="15.+" />
</plugin>

我的猜测是 Firebase 和 Google 服务版本存在问题,但我不完全确定...我尝试了多个版本,但似乎无法弄清楚。

有什么想法吗?

【问题讨论】:

你的 build.gradle 看起来不正确,***.com/questions/51072319/… @shizhen 怎么了? maven和jcenter的顺序? 是的,它可能与您的问题无关,但请在阅读您的帖子时发现这一点。 您是否尝试将目标 android SDK 版本更改为 26 ? @DelwynPinto 26?我试过了还是不行 【参考方案1】:

我解决了这个问题。我的cordova-plugin-firebasecordova-plugin-google-analytics 发生了冲突,所以我最终不得不将cordova-plugin-google-analytics 降级到版本1.8.3,这最终对我有用。

最后的简单修复,但从错误日志中绝对 0 指示这可能是问题所在。非常令人沮丧。

【讨论】:

在添加 cordova-plugin-firebase 并删除 cordova-plugin-google-analytics 后,我遇到了一个非常相似的问题。如果cordova-plugin-google-analytics 目录仍然缓存在我的plugins 目录下,我仍然遇到问题,即我不仅要删除cordova-plugin-google-analytics,还要从插件目录中手动删除该文件夹(在项目顶层)。【参考方案2】:

你必须做什么

    从您的项目中删除 Platform 文件夹。 使用 android 打开您的 ionic 项目 工作室

现在在 android studio 中运行以下命令:

ionic Cordova build 然后它要求输入 android 和 ios 然后输入 Android

欢迎评论以获得更多帮助 :)

【讨论】:

你也可以删除你的 node-module 文件夹,然后运行 ​​ionic serve 和 yes 再次安装 node 模块...有时会导致 node 版本冲突。不要害怕,要有耐心。 :)【参考方案3】:

我也遇到过这样的问题。 我的问题是cordova-plugin-firebase。 请按照以下步骤操作。

1.移除 Android 平台。

ionic cordova platform rm android

2。移除 cordova-plugin-firebase 插件。

ionic cordova plugin rm cordova-plugin-firebase

3.使用 1.0.0 版本再次添加 cordova-plugin-firebase 插件。

ionic cordova plugin add cordova-plugin-firebase@1.0.0

4.再次添加 Android 平台。

ionic cordova platform add android

5.为 Android 构建 Ionic 应用

ionic cordova build android

请随时评论您遇到的任何问题。

【讨论】:

恐怕这对我不起作用。我遇到了同样的问题 您在尝试之前尝试过github.com/ionic-team/ionic-cli/issues/… 从您的config.xml 文件中删除&lt;plugin name="cordova-android-support-gradle-release" spec="1.4.7"&gt; &lt;variable name="ANDROID_SUPPORT_VERSION" value="15.+" /&gt; &lt;/plugin&gt; &lt;plugin name="cordova-android-firebase-gradle-release" spec="^2.0.0"&gt; &lt;variable name="FIREBASE_VERSION" value="15.+" /&gt; &lt;/plugin&gt;

以上是关于任务':app:transformClassesWithDesugarForRelease'的离子执行失败的主要内容,如果未能解决你的问题,请参考以下文章

Gradle脚本小总结

任务 ':app:checkDebugAarMetadata 执行失败

任务 ':app:hiltJavaCompileDebug' 执行失败

任务 ':app:processDebugResources'.1 执行失败

错误:任务 ':app:transformClassesWithDexForDebug' Gradle 执行失败

苹果手机试玩app如何无限做任务技术教程!