简体   繁体   English

当我添加Apache POI库时,获取“:app:mergeDebugResources FAILED”

[英]Getting “:app:mergeDebugResources FAILED” when I add Apache POI lib

This problem has given me headache for many hours! 这个问题使我头痛了好几个小时! Everytime I add the Apache POI 3.14 lib into Android Studio, I get the same error: 每当我将Apache POI 3.14库添加到Android Studio中时,都会出现相同的错误:

Error:Execution failed for task ':app:mergeDebugResources'.
> -1

I can't run my app and I have tried to both clean and rebuild the project without any succses at all. 我无法运行我的应用程序,并且尝试了清理和重建项目而没有任何成功。

This is the file I downloaded Binary Distribution (zip): https://poi.apache.org/download.html 这是我下载的二进制分发文件(zip): https : //poi.apache.org/download.html

and then I unpacked it, and added the jar file poi-3.14-20160307.jar as a lib in Android Studio! 然后解压缩它,并将jar文件poi-3.14-20160307.jar为Android Studio中的lib!

I want to use this lib to read XLS/XLSX files in Android. 我想使用此库在Android中读取XLS / XLSX文件。

This is what is shown in the gradle console: 这是gradle控制台中显示的内容:

BUILD FAILED

Total time: 2.206 secs
Executing tasks: [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:assembleDebug]

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2411Library
:app:prepareComAndroidSupportAppcompatV72411Library
:app:prepareComAndroidSupportSupportV42411Library
:app:prepareComAndroidSupportSupportVectorDrawable2411Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> -1

Please note that there are a number of problems that you might run into when using Apache POI on Android. 请注意,在Android上使用Apache POI时,您可能会遇到许多问题。 Usually Android applications fail to build because there are too many methods or duplicate classes in XmlBeans or other build-related problems. 通常,Android应用程序无法构建,因为XmlBeans中的方法太多或类重复或其他与构建相关的问题。

There are currently two projects which try to solve most of the problems for you: 当前有两个项目试图为您解决大多数问题:

  1. https://github.com/andruhon/android5xlsx https://github.com/andruhon/android5xlsx
  2. https://github.com/centic9/poi-on-android/ (mainted by me) https://github.com/centic9/poi-on-android/ (由我维护)

The first one is currently based on POI 3.12, whereas the second can be re-compiled with newer versions of POI more easily. 当前,第一个基于POI 3.12,而第二个可以更轻松地与更新版本的POI重新编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM