本文介绍了android apache poi-ooxml导致构建错误"app:transformClassesWithDesugarForDebug"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a requirement in my app to implement excel creation and download. I have used Apache POI's HSSFWorkbook to implement the functionality. The app created the required excel (xls) output successfully.
However if I include apache:poi-ooxml in gradle and use XSSFWorkbook to create xlsx file for the same, I am getting the following error:

D:\USERS\PATH_TO_PROJECT>gradlew build

任务:app:compileDebugJavaWithJavac注意:某些输入文件使用或覆盖不推荐使用的API.注意:有关详细信息,请使用-Xlint:deprecation重新编译.注意:某些输入文件使用未经检查或不安全的操作.注意:重新编译-Xlint:unchecked以获得详细信息.

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.

线程主"中的异常java.lang.IllegalStateException:期望仅初始化此接口中的字段.owner = org/apache/xmlbeans/impl/xb/ltgfmt/Code $ 1,期望= org/apache/xmlbeans/impl/xb/ltgfmt/Code 在com.google.common.base.Preconditions.checkState(Preconditions.java:721)在com.google.devtools.build.android.desugar.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.desugar.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)

Exception in thread "main" java.lang.IllegalStateException: Expect only the fields in this interface to be initialized. owner=org/apache/xmlbeans/impl/xb/ltgfmt/Code$1, expected=org/apache/xmlbeans/impl/xb/ltgfmt/Code at com.google.common.base.Preconditions.checkState(Preconditions.java:721) at com.google.devtools.build.android.desugar.InterfaceDesugaring$InterfaceFieldWriteCollector.visitFieldInsn(InterfaceDesugaring.java:260) at org.objectweb.asm.MethodVisitor.visitFieldInsn(Unknown Source) at org.objectweb.asm.tree.FieldInsnNode.accept(Unknown Source) at org.objectweb.asm.tree.InsnList.accept(Unknown Source) at org.objectweb.asm.tree.MethodNode.accept(Unknown Source) at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitEnd(LambdaDesugaring.java:383) at org.objectweb.asm.MethodVisitor.visitEnd(Unknown Source) at org.objectweb.asm.MethodVisitor.visitEnd(Unknown Source) at org.objectweb.asm.ClassReader.b(Unknown Source) at org.objectweb.asm.ClassReader.accept(Unknown Source) at org.objectweb.asm.ClassReader.accept(Unknown Source) at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:401) at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:326) at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:280) at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:583)

失败:构建失败,并出现异常.

FAILURE: Build failed with an exception.

出了什么问题:错误:任务':app:transformClassesWithDesugarForDebug'的执行失败.

What went wrong:Error:Execution failed for task ':app:transformClassesWithDesugarForDebug'.

我已经搜索了'app:transformClassesWithDesugarForDebug'作为关键字,但是我得到的只是解决方案'app:transformClassesWithDexForDebug'.

I have searched with 'app:transformClassesWithDesugarForDebug' as keyword, but all I get is solution 'app:transformClassesWithDexForDebug'.

请提供解决方案的链接并进行说明.我知道在我阅读Android文档此处.我需要知道是什么文件导致了这些错误.

Please provide link for solution and explain. I know that desugar transforms class files to desugared class files (to enable new features), as I read on Android docs here. I need to know what files are making these errors.

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

NOTE: I have even set the multiDexEnabled true in gradle, still same error. Please give me solution for this problem, also please see bold lines in the error stack, I think that is the clue to the answer but I am unable to find it. For time sake, I have used HSSFWorkbook(xls), but I need XSSFWorkbook to create xlsx file.

谢谢...

推荐答案

更改您的porject/build.gralde

change your porject/build.gralde

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

重建.......好吧,我更改此文件.重建......成功编译apk!希望对您有帮助

rebuild .......ok,I change this file. rebuild ......Compile apk successfully!Hope it helps you

这篇关于android apache poi-ooxml导致构建错误"app:transformClassesWithDesugarForDebug"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 18:26