title: Dependencies for using Apache POI to read excel files in Android
body: <p>I want to use Apache POI to read and write excel files (both xlsx and xls) in Android. But I cannot resolve dependency issues that I currently have.</p>
  
  <p>If I have only these two dependencies in my gradle file</p>
  
  <pre><code>compile files('libs/poi-3.12-20150511.jar')
  compile files('libs/poi-ooxml-3.12-20150511.jar')
  </code></pre>
  
  <p>Then I get the following error:</p>
  
  <pre><code>   java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/xmlbeans/XmlOptions;
              at org.apache.poi.POIXMLDocumentPart.&lt;clinit&gt;(POIXMLDocumentPart.java:59)
              at com.gargzdai.spreadsheet.MainActivity.readData(MainActivity.java:131)
              at com.gargzdai.spreadsheet.MainActivity.prepareForReadingData(MainActivity.java:109)
              at com.gargzdai.spreadsheet.MainActivity.onCreate(MainActivity.java:68)
              at android.app.Activity.performCreate(Activity.java:5990)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
              at android.app.ActivityThread.access$800(ActivityThread.java:151)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5254)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
  </code></pre>
  
  <p>This is the code I'm using to read excel files:</p>
  
  <pre><code>    if (isXlsxFile)
          myWorkbook = new XSSFWorkbook(OPCPackage.open(file));
      else
          myWorkbook = new HSSFWorkbook(fileStream);
      Sheet mySheet = myWorkbook.getSheetAt(0);
      Iterator rowIterator = mySheet.rowIterator();
  </code></pre>
  
  <p>It seems that I should add xmlbeans library. After I add this dependency to my gradle file:</p>
  
  <pre><code>compile files('libs/xmlbeans-2.6.0.jar')
  </code></pre>
  
  <p>After I add this dependency I get the following error during gradle build:</p>
  
  <pre><code>Error:Execution failed for task ':app:preDexDebug'.
  &gt; com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_40\bin\java.exe'' finished with non-zero exit value 1
  </code></pre>
  
  <p>Any ideas on how should I approach this problem?</p>