递归火山软件开发平台

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 火山 源码 类库
查看: 2376|回复: 4
打印 上一主题 下一主题

[安卓] 错误: 步骤"生成DEX文件"执行失败

[复制链接]

28

主题

122

帖子

572

积分

高级会员

Rank: 4

积分
572
跳转到指定楼层
楼主
发表于 2024-3-20 14:29:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
--- 开始编译项目"Word_Excel处理":
编译生成对应的Java源文件到目录"C:\Users\52242\AppData\Roaming\VolDev\视窗+安卓+服务器\简体中文\测试版\_sys_sln_tmp\samples\vprj_android\_int\PoiOffice\debug\project\src"成功 [双击可跳转]
正在链接生成安卓APK输出文件"C:\Users\52242\AppData\Roaming\VolDev\视窗+安卓+服务器\简体中文\测试版\_sys_sln_tmp\samples\vprj_android\_int\PoiOffice\debug\linker\PoiOffice.apk"
当前程序编译时所需求安卓SDK API版本: 30, 实际所使用版本: 30;  运行时所需求API版本: 21
当前程序所需求Java SDK版本: 1.8;  实际所使用版本: 1.8
正在进行"编译Java源文件"工作,请稍候...
正在进行"生成DEX文件"工作,请稍候...
错误:
    步骤"生成DEX文件"执行失败
    Warning in libs\poi-ooxml-3.9-20121203.jarrg/apache/poi/xslf/usermodel/RenderableShape.class:
      Type `java.awt.AlphaComposite` was not found, it is required for default or static interface methods desugaring of `java.awt.Paint org.apache.poi.xslf.usermodel.RenderableShape.createTexturePaint(org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties, java.awt.Graphics2D, org.apache.poi.openxml4j.opc.PackagePart)`
    Warning in libs\poi-ooxml-3.9-20121203.jarrg/apache/poi/xslf/usermodel/RenderableShape.class:
      Type `java.awt.geom.AffineTransform` was not found, it is required for default or static interface methods desugaring of `java.awt.Paint org.apache.poi.xslf.usermodel.RenderableShape.createLinearGradientPaint(java.awt.Graphics2D, org.openxmlformats.schemas.drawingml.x2006.main.CTGradientFillProperties, java.awt.geom.Rectangle2D, org.apache.poi.xslf.usermodel.XSLFTheme, org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor)`
    Warning in libs\dom4j-1.6.1.jarrg/dom4j/io/XPPReader.class:
      Type `org.gjt.xpp.XmlPullParserFactory` was not found, it is required for default or static interface methods desugaring of `org.gjt.xpp.XmlPullParserFactory org.dom4j.io.XPPReader.getXPPFactory()`
    Warning in libs\xmlbeans-2.3.0.jarrg/apache/xmlbeans/impl/jam/internal/javadoc/JavadocRunner.class:
      Type `com.sun.tools.javadoc.Main` was not found, it is required for default or static interface methods desugaring of `com.sun.javadoc.RootDoc org.apache.xmlbeans.impl.jam.internal.javadoc.JavadocRunner.run(java.io.File[], java.io.PrintWriter, java.lang.String, java.lang.String, java.lang.String[], org.apache.xmlbeans.impl.jam.provider.JamLogger)`
    Warning in libs\poi-3.9-20121203.jarrg/apache/poi/util/FontMetricsDumper.class:
      Type `java.awt.GraphicsEnvironment` was not found, it is required for default or static interface methods desugaring of `void org.apache.poi.util.FontMetricsDumper.main(java.lang.String[])`
    Warning in libs\poi-3.9-20121203.jarrg/apache/poi/util/FontMetricsDumper.class:
      Type `java.awt.Toolkit` was not found, it is required for default or static interface methods desugaring of `void org.apache.poi.util.FontMetricsDumper.main(java.lang.String[])`
    Warning in libs\dom4j-1.6.1.jarrg/dom4j/datatype/SchemaParser.class:
      Type `com.sun.msv.datatype.xsd.DatatypeFactory` was not found, it is required for default or static interface methods desugaring of `com.sun.msv.datatype.xsd.XSDatatype org.dom4j.datatype.SchemaParser.getTypeByName(java.lang.String)`
    Warning in libs\poi-3.9-20121203.jarrg/apache/poi/poifs/crypt/EncryptionVerifier.class:
      Type `org.apache.commons.codec.binary.Base64` was not found, it is required for default or static interface methods desugaring of `void org.apache.poi.poifs.crypt.EncryptionVerifier.<init>(java.lang.String)`
    Warning in libs\dom4j-1.6.1.jarrg/dom4j/jaxb/JAXBSupport.class:
      Type `javax.xml.bind.JAXBContext` was not found, it is required for default or static interface methods desugaring of `javax.xml.bind.JAXBContext org.dom4j.jaxb.JAXBSupport.getContext()`
    Warning in libs\poi-ooxml-3.9-20121203.jarrg/apache/poi/util/OOXMLLite.class:
      Type `junit.textui.TestRunner` was not found, it is required for default or static interface methods desugaring of `void org.apache.poi.util.OOXMLLite.build()`
    Warning in libs\dom4j-1.6.1.jar:org/dom4j/bean/BeanMetaData.class:
      Type `java.beans.Introspector` was not found, it is required for default or static interface methods desugaring of `void org.dom4j.bean.BeanMetaData.<init>(java.lang.Class)`
    Warning in libs\poi-ooxml-3.9-20121203.jar:org/apache/poi/xslf/usermodel/XSLFPictureShape.class:
      Type `javax.imageio.ImageIO` was not found, it is required for default or static interface methods desugaring of `void org.apache.poi.xslf.usermodel.XSLFPictureShape.resize()`
    Warning in libs\poi-3.9-20121203.jar:org/apache/poi/util/CommonsLogger.class:
      Type `org.apache.commons.logging.LogFactory` was not found, it is required for default or static interface methods desugaring of `void org.apache.poi.util.CommonsLogger.<clinit>()`
    Warning in libs\aar_com-android-support-compat-28_classes.jar:android/support/v4/app/SupportActivity.class:
      Type `android.arch.lifecycle.ReportFragment` was not found, it is required for default or static interface methods desugaring of `void android.support.v4.app.SupportActivity.onCreate(android.os.Bundle)`
    Warning in libs\poi-3.9-20121203.jar:org/apache/poi/hssf/usermodel/HSSFWorkbook.class:
      Type `org.apache.commons.codec.digest.DigestUtils` was not found, it is required for default or static interface methods desugaring of `int org.apache.poi.hssf.usermodel.HSSFWorkbook.addPicture(byte[], int)`
    Warning in libs\dom4j-1.6.1.jar:org/dom4j/xpath/XPathPattern.class:
      Type `org.jaxen.pattern.PatternParser` was not found, it is required for default or static interface methods desugaring of `void org.dom4j.xpath.XPathPattern.<init>(java.lang.String)`
    Warning in libs\dom4j-1.6.1.jar:org/dom4j/xpath/XPathPattern.class:
      Type `org.jaxen.XPathFunctionContext` was not found, it is required for default or static interface methods desugaring of `org.jaxen.ContextSupport org.dom4j.xpath.XPathPattern.getContextSupport()`
    Warning in libs\dom4j-1.6.1.jar:org/dom4j/xpath/XPathPattern.class:
      Type `org.jaxen.dom4j.DocumentNavigator` was not found, it is required for default or static interface methods desugaring of `org.jaxen.ContextSupport org.dom4j.xpath.XPathPattern.getContextSupport()`
    Warning in libs\dom4j-1.6.1.jar:org/dom4j/datatype/DatatypeElement.class:
      Type `com.sun.msv.datatype.SerializationContext` was not found, it is required for default or static interface methods desugaring of `org.dom4j.datatype.DatatypeElement`
    Warning in libs\dom4j-1.6.1.jar:org/dom4j/datatype/DatatypeElement.class:
      Type `org.relaxng.datatype.ValidationContext` was not found, it is required for default or static interface methods desugaring of `org.dom4j.datatype.DatatypeElement`
    Warning in libs\dom4j-1.6.1.jar:org/dom4j/swing/XMLTableDefinition.class:
      Type `org.jaxen.VariableContext` was not found, it is required for default or static interface methods desugaring of `org.dom4j.swing.XMLTableDefinition`
    Warning in libs\xmlbeans-2.3.0.jar:org/apache/xmlbeans/impl/jam/internal/javadoc/JavadocRunner.class:
      Type `com.sun.javadoc.Doclet` was not found, it is required for default or static interface methods desugaring of `org.apache.xmlbeans.impl.jam.internal.javadoc.JavadocRunner`
    Warning in libs\dom4j-1.6.1.jar:org/dom4j/xpath/DefaultNamespaceContext.class:
      Type `org.jaxen.NamespaceContext` was not found, it is required for default or static interface methods desugaring of `org.dom4j.xpath.DefaultNamespaceContext`
    Warning in libs\poi-ooxml-3.9-20121203.jar:org/apache/poi/xslf/usermodel/XSLFRenderingHint.class:
      Type `java.awt.RenderingHints$Key` was not found, it is required for default or static interface methods desugaring of `org.apache.poi.xslf.usermodel.XSLFRenderingHint`
    Warning in libs\poi-3.9-20121203.jar:org/apache/poi/hssf/usermodel/EscherGraphics2d.class:
      Type `java.awt.Graphics2D` was not found, it is required for default or static interface methods desugaring of `org.apache.poi.hssf.usermodel.EscherGraphics2d`
    Warning in libs\aar_com-android-support-compat-28_classes.jar:android/support/v4/graphics/drawable/IconCompat.class:
      Type `androidx.versionedparcelable.CustomVersionedParcelable` was not found, it is required for default or static interface methods desugaring of `android.support.v4.graphics.drawable.IconCompat`
    Warning in libs\dom4j-1.6.1.jar:org/dom4j/swing/DocumentTreeModel.class:
      Type `javax.swing.tree.DefaultTreeModel` was not found, it is required for default or static interface methods desugaring of `org.dom4j.swing.DocumentTreeModel`
    Warning in libs\xmlbeans-2.3.0.jar:org/apache/xmlbeans/impl/tool/XMLBean.class:
      Type `org.apache.tools.ant.taskdefs.MatchingTask` was not found, it is required for default or static interface methods desugaring of `org.apache.xmlbeans.impl.tool.XMLBean`
    Warning in libs\poi-3.9-20121203.jar:org/apache/poi/hssf/usermodel/EscherGraphics.class:
      Type `java.awt.Graphics` was not found, it is required for default or static interface methods desugaring of `org.apache.poi.hssf.usermodel.EscherGraphics`
    Warning in libs\dom4j-1.6.1.jar:org/dom4j/swing/LeafTreeNode.class:
      Type `javax.swing.tree.TreeNode` was not found, it is required for default or static interface methods desugaring of `org.dom4j.swing.LeafTreeNode`
    Warning in libs\aar_com-android-support-compat-28_classes.jar:android/support/v4/app/SupportActivity.class:
      Type `android.arch.lifecycle.LifecycleOwner` was not found, it is required for default or static interface methods desugaring of `android.support.v4.app.SupportActivity`
    Warning in libs\dom4j-1.6.1.jar:org/dom4j/xpp/ProxyXmlStartTag.class:
      Type `org.gjt.xpp.XmlStartTag` was not found, it is required for default or static interface methods desugaring of `org.dom4j.xpp.ProxyXmlStartTag`
    Warning in libs\dom4j-1.6.1.jar:org/dom4j/swing/XMLTableModel.class:
      Type `javax.swing.table.AbstractTableModel` was not found, it is required for default or static interface methods desugaring of `org.dom4j.swing.XMLTableModel`
    Error: Cannot fit requested classes in a single dex file (# methods: 111805 > 65536). Try supplying a main-dex list
    Compilation failed
错误: 建立所指定的安卓APK输出文件"C:\Users\52242\AppData\Roaming\VolDev\视窗+安卓+服务器\简体中文\测试版\_sys_sln_tmp\samples\vprj_android\_int\PoiOffice\debug\linker\PoiOffice.apk"失败
--- 项目"Word_Excel处理"编译或链接失败. 编译过程中共遇到了 0 个警告, 2 个错误.


这个是什么情况??怎么解决

回复

使用道具 举报

36

主题

444

帖子

1550

积分

金牌会员

Rank: 6Rank: 6

积分
1550
QQ
沙发
发表于 2024-3-20 22:40:57 | 只看该作者
这些警告和错误信息表明您在尝试编译或打包一个包含Apache POI以及其他相关库(如DOM4J、XMLBeans等)的Java项目时遇到了问题。该项目目标是运行在Android平台上,但在处理过程中的desugaring阶段(用于兼容低版本Android API的方法转换)缺失了一些必要的类。

例如,许多警告显示了诸如java.awt.*、javax.imageio.*、org.apache.commons.logging.*、javax.swing.* 等类找不到,这些都是Java标准版(Java SE)中的类,它们并不包含在Android SDK中,所以无法在Android环境中运行。

此外,还有关于dex文件方法数超过限制的错误:

Error: Cannot fit requested classes in a single dex file (# methods: 111805 > 65536). Try supplying a main-dex list

这意味着您的应用中引用的类和方法数量超过了Dalvik Executable (DEX) 文件的最大方法数限制(默认是65536个方法)。要解决这个问题,通常有以下几种方法:

Proguard优化:启用代码压缩和混淆,可以减少最终APK中的方法数量。

Multidex支持:对于Android 5.0 噜阿噜lipop之前的版本,需要开启multidex支持,允许应用分多个DEX文件存储方法。

在模块级别的build.gradle文件中添加 multidex 支持:

Groovy
android {
    defaultConfig {
        multiDexEnabled true
    }
}
dependencies {
    implementation 'com.android.support:multidex:1.0.3' // 或者更新的版本
}
如果是应用主入口(通常是Application类),继承自MultiDexApplication。

提供main-dex列表:手动指定哪些类必须包含在主DEX文件中,以确保核心功能正常运行。

综上所述,由于POI库主要用于处理Microsoft Office文档,其依赖的大量Java SE库并不适合Android环境。如果要在Android上处理Office文档,建议寻找专门为Android设计的库,如Apache POI的某些子项目或者第三方的Android友好的库,如andOTP或docx4j-for-android等。对于Android上的Excel操作,可以考虑使用像androidxlsx这样的库。

有问题 问AI
Q 75520266
回复

使用道具 举报

444

主题

1万

帖子

4万

积分

超级版主

Rank: 8Rank: 8

积分
40581
板凳
发表于 2024-3-21 08:38:52 | 只看该作者
这个要启用apk分包机制,免费版用不了。
安卓无障碍实战课:点击查看
交流群:641526939
回复

使用道具 举报

1

主题

8

帖子

91

积分

核心用户

Rank: 9Rank: 9Rank: 9

积分
91
地板
发表于 2024-8-22 09:41:12 | 只看该作者
创世魂 发表于 2024-3-21 08:38
这个要启用apk分包机制,免费版用不了。

个人版不是免费版
回复

使用道具 举报

1

主题

8

帖子

91

积分

核心用户

Rank: 9Rank: 9Rank: 9

积分
91
5#
发表于 2024-8-22 09:43:33 | 只看该作者
承易 发表于 2024-3-20 22:40
这些警告和错误信息表明您在尝试编译或打包一个包含Apache POI以及其他相关库(如DOM4J、XMLBeans等)的Jav ...

对样例进行调试又不会报错
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|递归火山软件开发平台 ( 鄂ICP备18029190号 )

GMT+8, 2024-11-27 09:46 , Processed in 0.088497 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表