apache poi - 任务 ':app:preDexDebug' 的执行失败。> com.android.ide.common.process.ProcessException:



我正在尝试将apache POI库与我的android应用程序集成。为此,我将apache poi jar文件添加到了我的libs文件夹中,并使用"编译文件"通过build.gradle进行编译。但当我进行渐变同步时,它没有问题。在进行渐变同步后,当我尝试运行应用程序时,我收到错误Execution Failed For task":app:preDexDebug"。

我见过以下类似的问题,但没有用。

错误:任务';的执行失败:app:preDexDebug';

https://stackoverflow.com/questions/27437049/android-studio-gradle-execution-failed-for-task-apppredexdebug

以下是我的等级依赖:

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.1.1'
compile files('libs/poi-3.12-20150511.jar')
compile files('libs/poi-ooxml-3.12-20150511.jar')
compile files('libs/poi-ooxml-schemas-3.12-20150511.jar')
compile files('libs/xmlbeans-2.6.0.jar') 
}

错误消息:

Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException: 
  Process 'command 'C:Program FilesJavajdk1.8.0_31binjava.exe'' 
  finished with non-zero exit value 1

渐变控制台输出:

:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:preDexDebug
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"}
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.XmlBeans$1) that doesnu0027t come with an","position":{},"original":"(org.apache.xmlbeans.XmlBeans$1) that doesnu0027t come with an"}
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"}
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"}
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"}
AGPBI: {"kind":"SIMPLE","text":"and without specifying any "-target" type options. The consequence of ignoring","position":{},"original":"and without specifying any "-target" type options. The consequence of ignoring"}
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"}
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."}
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"}
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.XmlSimpleList$1) that doesnu0027t come with an","position":{},"original":"(org.apache.xmlbeans.XmlSimpleList$1) that doesnu0027t come with an"}
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"}
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"}
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"}
AGPBI: {"kind":"SIMPLE","text":"and without specifying any "-target" type options. The consequence of ignoring","position":{},"original":"and without specifying any "-target" type options. The consequence of ignoring"}
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"}
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."}
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"}
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.XmlSimpleList$2) that doesnu0027t come with an","position":{},"original":"(org.apache.xmlbeans.XmlSimpleList$2) that doesnu0027t come with an"}
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"}
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"}
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"}
AGPBI: {"kind":"SIMPLE","text":"and without specifying any "-target" type options. The consequence of ignoring","position":{},"original":"and without specifying any "-target" type options. The consequence of ignoring"}
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"}
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."}
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"}
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$1) that doesnu0027t come with an","position":{},"original":"(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$1) that doesnu0027t come with an"}
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"}
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"}
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"}
AGPBI: {"kind":"SIMPLE","text":"and without specifying any "-target" type options. The consequence of ignoring","position":{},"original":"and without specifying any "-target" type options. The consequence of ignoring"}
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"}
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."}
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"}
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$2) that doesnu0027t come with an","position":{},"original":"(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$2) that doesnu0027t come with an"}
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"}
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"}
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"}
AGPBI: {"kind":"SIMPLE","text":"and without specifying any "-target" type options. The consequence of ignoring","position":{},"original":"and without specifying any "-target" type options. The consequence of ignoring"}
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"}
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."}
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"}
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$3) that doesnu0027t come with an","position":{},"original":"(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$3) that doesnu0027t come with an"}
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"}
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"}
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"}
AGPBI: {"kind":"SIMPLE","text":"and without specifying any "-target" type options. The consequence of ignoring","position":{},"original":"and without specifying any "-target" type options. The consequence of ignoring"}
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"}
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."}
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"}
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl$SchemaTypeLoaderCache$1) that doesnu0027t come with an","position":{},"original":"(org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl$SchemaTypeLoaderCache$1) that doesnu0027t come with an"}
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"}
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"}
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"}
AGPBI: {"kind":"SIMPLE","text":"and without specifying any "-target" type options. The consequence of ignoring","position":{},"original":"and without specifying any "-target" type options. The consequence of ignoring"}
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"}
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."}
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"}
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.impl.validator.ValidatingXMLInputStream$1) that doesnu0027t come with an","position":{},"original":"(org.apache.xmlbeans.impl.validator.ValidatingXMLInputStream$1) that doesnu0027t come with an"}

失败

失败:生成失败,出现异常。

  • 哪里出了问题:任务":app:preDexDebug"的执行失败。

    com.android.ide.common.prrocess.ProcessException:org.gradle.prrocess.internal.ExecException:进程"命令"C:\Program Files\Java\jdk1.8.0_31\bin\Java.exe"以非零退出值1 结束

  • 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。

生成失败的

总时间:22.982秒

在过去的两天里,我一直被这个错误所困扰,最后我选择了在android应用程序中搜索创建excel表的替代方法。

我尝试过使用"aspose"库,与"apachePoi"one_answers"jxl"库相比,它非常容易使用。

"Aspose"库的链接以及如何在android项目中使用。

http://www.aspose.com/android/total-component.aspx

https://github.com/asposecells/Aspose_Cells_Android

感谢在这种情况下帮助我的每一个人。

  1. 您是否尝试了以下顺序(按顺序):使缓存失效&重启=>渐变同步=>渐变清理=>渐变构建?

  2. 在文件=>项目结构=>SDK位置:您是否将JDK位置设置为指向JDK 7的有效安装?

  3. 你在模块的build.gradle中有这个吗?它触发了错误:

    android {
        ...
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }
    

相关内容

最新更新