3

I am using Apache POI in my android application to read xlsx file stored in SDCARD. I am using following jar libs from Apache POI

  1. poi-ooxml-schemas-3.9-20121203.jar
  2. poi-ooxml-3.9-20121203.jar

But when I try to Run Android App I am getting below mentioned stacktrace.

trouble writing output: Too many methods: 66024; max is 65536. By package:
    13 java.lang
     1 java.lang.reflect
     5 java.util
     1 javax.xml.namespace
    66 org.apache.xmlbeans
    19 org.apache.xmlbeans.impl.values
     1 org.apache.xmlbeans.impl.xb.xmlschema
  2500 org.openxmlformats.schemas.drawingml.x2006.chart
  1430 org.openxmlformats.schemas.drawingml.x2006.chart.impl
  8767 org.openxmlformats.schemas.drawingml.x2006.main
  5258 org.openxmlformats.schemas.drawingml.x2006.main.impl
    86 org.openxmlformats.schemas.drawingml.x2006.picture
    33 org.openxmlformats.schemas.drawingml.x2006.picture.impl
   745 org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing
   417 org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.impl
   230 org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing
   164 org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.impl
   298 org.openxmlformats.schemas.officeDocument.x2006.customProperties
   256 org.openxmlformats.schemas.officeDocument.x2006.customProperties.impl
   617 org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes
   596 org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes.impl
   285 org.openxmlformats.schemas.officeDocument.x2006.extendedProperties
   196 org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.impl
    23 org.openxmlformats.schemas.officeDocument.x2006.math
    24 org.openxmlformats.schemas.officeDocument.x2006.relationships
     2 org.openxmlformats.schemas.officeDocument.x2006.relationships.impl
  2076 org.openxmlformats.schemas.presentationml.x2006.main
  1224 org.openxmlformats.schemas.presentationml.x2006.main.impl
     1 org.openxmlformats.schemas.schemaLibrary.x2006.main
  7271 org.openxmlformats.schemas.spreadsheetml.x2006.main
  4556 org.openxmlformats.schemas.spreadsheetml.x2006.main.impl
 11448 org.openxmlformats.schemas.wordprocessingml.x2006.main
  9217 org.openxmlformats.schemas.wordprocessingml.x2006.main.impl
     4 schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707
  1170 schemasMicrosoftComOfficeExcel
  1223 schemasMicrosoftComOfficeExcel.impl
   285 schemasMicrosoftComOfficeOffice
   124 schemasMicrosoftComOfficeOffice.impl
     2 schemasMicrosoftComOfficePowerpoint
     3 schemasMicrosoftComOfficeWord
  2858 schemasMicrosoftComVml
  2529 schemasMicrosoftComVml.impl
[2013-11-25 21:20:32 - CRD] Conversion to Dalvik format failed with error 2

Can anyone tell where am I missing?

Ashwin N Bhanushali
  • 3,872
  • 5
  • 39
  • 59
  • 2
    Can You Please Refer @http://stackoverflow.com/questions/15200286/ . It may Useful to track the issue. – Subramanian Ramsundaram Nov 26 '13 at 17:38
  • I already looked at it.But can not solve the issue since they have not mentioned how to use proguard or custom ant library. – Ashwin N Bhanushali Nov 26 '13 at 17:39
  • someone at some point wrote that changing the order off the import in the classpath would help. But I had the same issue when I tried some time ago, ended up exporting the excel as CSV and reading that instead. – cYrixmorten Nov 26 '13 at 17:53
  • I tried with order of import but it did not work.I can not export to csv that is my app constraint can anyone suggest what to do? – Ashwin N Bhanushali Nov 26 '13 at 18:21
  • http://stackoverflow.com/questions/17485309/exception-occurs-while-opening-xlsx-file-using-apache-poi/17550202#17550202 –  Dec 02 '13 at 08:23

2 Answers2

1

If you use too much code for any android app, the compilation will throw this error. The similar problem is stated and resolved here. You should split the app in parts as a plugin, in the form of a separate APK available for download. That APK would expose some component that the main app would use. There are various app on google play of such kind.

Community
  • 1
  • 1
Sankumarsingh
  • 9,889
  • 11
  • 50
  • 74
1

Please note that there are a number of problems when using Apache POI on Android. The one you are hitting can be solved by the so called "multiDex" feature in newer versions of Android.

There are currently two projects which try to solve most of the problems for you:

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

The first one is currently based on POI 3.12, whereas the second can be re-compiled with newer versions of POI more easily.

centic
  • 15,565
  • 9
  • 68
  • 125