gpt4 book ai didi

android-gradle-plugin - android apache poi-ooxml 导致构建错误 'app:transformClassesWithDesugarForDebug'

转载 作者:行者123 更新时间:2023-12-03 01:29:53 25 4
gpt4 key购买 nike

我的应用程序需要实现 Excel 创建和下载。我使用 Apache POI 的 HSSFWorkbook 来实现该功能。应用程序成功创建了所需的 Excel (xls) 输出。
但是,如果我在 gradle 中包含 apache:poi-ooxml 并使用 XSSFWorkbook 为其创建 xlsx 文件,则会收到以下错误:

D:\USERS\PATH_TO_PROJECT>gradlew build

Configure project :app Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.

Task :app:compileDebugJavaWithJavac Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

线程“main”中出现异常 java.lang.IllegalStateException:仅期望初始化此接口(interface)中的字段。所有者=org/apache/xmlbeans/impl/xb/ltgfmt/Code$1,预期=org/apache/xmlbeans/impl/xb/ltgfmt/代码 在 com.google.common.base.Preconditions.checkState(Preconditions.java:721) 在 com.google.devtools.build.android.desugaring.InterfaceDesugaring$InterfaceFieldWriteCollector.visitFieldInsn(InterfaceDesugaring.java:260) 在 org.objectweb.asm.MethodVisitor.visitFieldInsn(来源未知) 在 org.objectweb.asm.tree.FieldInsnNode.accept(来源未知) 在 org.objectweb.asm.tree.InsnList.accept(来源未知) 在 org.objectweb.asm.tree.MethodNode.accept(来源未知) 在 com.google.devtools.build.android.desugaring.LambdaDesugaring$InvokedynamicRewriter.visitEnd(LambdaDesugaring.java:383) 在 org.objectweb.asm.MethodVisitor.visitEnd(来源未知) 在 org.objectweb.asm.MethodVisitor.visitEnd(来源未知) 在 org.objectweb.asm.ClassReader.b(来源未知) 在 org.objectweb.asm.ClassReader.accept(来源未知) 在 org.objectweb.asm.ClassReader.accept(来源未知) 在 com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:401) 在 com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:326) 在 com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:280) 在 com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:583)

失败:构建因异常而失败。

出了什么问题:错误:任务“:app:transformClassesWithDesugarForDebug”执行失败。

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 C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\org.apache.xmlbeans\xmlbeans\2.6.0\29e80d2dd51f9dcdef8f9ffaee0d4dc1c9bbfc87\xmlbeans-2.6.0.jar --output D:\USERS\PATH_TO_PROJECT\app\build\intermediates\transforms\desugar\debug\30.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\design-26.0.0.aar\88757c55175e8007a9a997cb5c307f06\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.0.0.aar\9b22a71aa7416871ab6c4351056e3163\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\constraint-layout-1.0.2.aar\3113031e47d9da0b206f8a6d5dc5ddb5\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\cardview-v7-26.0.0.aar\44a7b81392464ba1ca65bd40f2e71204\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\gridlayout-v7-26.0.0.aar\0d2a4abaa9e93e5e2ca39f668099f366\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\acra-4.9.2.aar\a95cb5a22663d0060239228bd98b8433\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\transition-26.0.0.aar\bf06e65e1453c6ecba1710c6d321fc23\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\adapters-1.3.1.aar\53fb1dbf25549b14049acaaa62d454b7\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\library-1.3.1.aar\54ece89f3ae5343b4010f6a6ec76b51c\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-v4-26.0.0.aar\30b6c2f5af04a368bb3ba3da5a12978e\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\recyclerview-v7-26.0.0.aar\ecbf0b20322f38889946e58312686426\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\com.google.code.gson\gson\2.8.0\c4ba5371a29ac9b2ad6129b1d39ea38750043eff\gson-2.8.0.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\com.annimon\stream\1.1.7\a71f0635ac38194d70094e53f6fd89e00a93c834\stream-1.1.7.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi-ooxml\3.16\76e20fe22404cc4da55ddfdaaaadee32bbfa3bdd\poi-ooxml-3.16.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi\3.16\ad21c123ee5d6b5b2a8f0d4ed23b3ffe6759a889\poi-3.16.jar --classpath_entry D:\android-studio-preview\gradle\m2repository\com\android\databinding\baseLibrary\3.0.0-beta1\baseLibrary-3.0.0-beta1.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\animated-vector-drawable-26.0.0.aar\e436cd2461e582de2e8dd0f296ecb608\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-vector-drawable-26.0.0.aar\0a153ef2b3a29b2746c4ade8c57868f8\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-fragment-26.0.0.aar\90abaab734f5b5dc1ebf43c2e1e6a5b7\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-core-ui-26.0.0.aar\0c1bca53056184d4f28ea1a21be505f5\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-media-compat-26.0.0.aar\912ee7959b738daba3efb4d6cb162083\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-core-utils-26.0.0.aar\8052717d55d9db1adc43a2838ce31976\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-compat-26.0.0.aar\69023f52457cfb4013657fbef040bfec\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\com.android.support\support-annotations\26.0.0\db09a97f4f0db8892c1a0111a4b966f97920d082\support-annotations-26.0.0.jar --classpath_entry D:\SOFTWARES\AndroidSDK\extras\m2repository\com\android\support\constraint\constraint-layout-solver\1.0.2\constraint-layout-solver-1.0.2.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\multidex-1.0.1.aar\f429f7a46c1e6dc7d9deaabf508265bf\jars\classes.jar --classpath_entry D:\SOFTWARES\android-studio-preview\gradle\m2repository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-collections4\4.1\a4cf4688fe1c7e3a63aa636cc96d013af537768e\commons-collections4-4.1.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi-ooxml-schemas\3.16\9828a49307fc6bebfd42185b677d88b6e4994c63\poi-ooxml-schemas-3.16.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\com.github.virtuald\curvesapi\1.04\3386abf821719bc89c7685f9eaafaf4a842f0199\curvesapi-1.04.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\org.apache.xmlbeans\xmlbeans\2.6.0\29e80d2dd51f9dcdef8f9ffaee0d4dc1c9bbfc87\xmlbeans-2.6.0.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\stax\stax-api\1.0.1\49c100caf72d658aca8e58bd74a4ba90fa2b0d70\stax-api-1.0.1.jar --classpath_entry D:\USERS\PATH_TO_PROJECT\app\build\intermediates\classes\debug --bootclasspath_entry D:\AndroidSDK\platforms\android-26\android.jar --bootclasspath_entry D:\AndroidSDK\platforms\android-26\optional\org.apache.http.legacy.jar --bootclasspath_entry D:\SOFTWARES\android-studio-preview\jre\jre\lib\resources.jar --bootclasspath_entry D:\android-studio-preview\jre\jre\lib\rt.jar --bootclasspath_entry D:\android-studio-preview\jre\jre\lib\jsse.jar --bootclasspath_entry D:\android-studio-preview\jre\jre\lib\jce.jar --bootclasspath_entry D:\android-studio-preview\jre\jre\lib\charsets.jar --min_sdk_version 16 --desugar_try_with_resources_if_needed --desugar_try_with_resources_omit_runtime_classes}

我使用“app:transformClassesWithDesugarForDebug”作为关键字进行搜索,但我得到的只是解决方案“app:transformClassesWithDexForDebug”。

请提供解决方案的链接并进行解释。我知道脱糖将类文件转换为脱糖类文件(以启用新功能),正如我在 Android 文档 here 上读到的那样。我需要知道哪些文件导致了这些错误。

注意:我什至在 gradle 中设置了 multiDexEnabled true ,仍然是同样的错误。请给我这个问题的解决方案,还请查看错误堆栈中的粗体行,我认为这是答案的线索,但我无法找到它。由于时间原因,我使用了 HSSFWorkbook(xls),但我需要 XSSFWorkbook 来创建 xlsx 文件。

谢谢...

最佳答案

更改您的项目/build.gradle

compileOptions {
//sourceCompatibility JavaVersion.VERSION_1_8
//targetCompatibility JavaVersion.VERSION_1_8
}

重建......好的,我改变这个文件。重建......编译apk成功!希望对您有帮助

关于android-gradle-plugin - android apache poi-ooxml 导致构建错误 'app:transformClassesWithDesugarForDebug',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45614931/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com