centic9 / poi-on-android

A sample project that shows how Apache POI can be used in an Android application
Apache License 2.0
357 stars 89 forks source link

I am using XSSFWorkbook on Android but am facing an error like this java.lang.NoClassDefFoundError: Failed resolution of: Ljavax #77

Closed saeedalaloul closed 4 years ago

saeedalaloul commented 4 years ago

Log:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.alansar.center, PID: 12389 java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLStreamReader; at org.apache.xmlbeans.XmlBeans.buildStreamToNodeMethod(XmlBeans.java:251) at org.apache.xmlbeans.XmlBeans.(XmlBeans.java:138) at org.apache.xmlbeans.XmlBeans.typeLoaderForClassLoader(XmlBeans.java:719) at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook$Factory.getTypeLoader(Unknown Source:25) at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook$Factory.newInstance(Unknown Source:0) at org.apache.poi.xssf.usermodel.XSSFWorkbook.onWorkbookCreate(XSSFWorkbook.java:456) at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:259) at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:253) at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:241) at com.alansar.center.Mohafez.Fragment.Monthly_Reports_Fragment.onCreateView(Monthly_Reports_Fragment.java:65) at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303) at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439) at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079) at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869) at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824) at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727) at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.stream.XMLStreamReader" on path: DexPathList[[zip file "/data/app/com.alansar.center-5QLoQbFk5EpZJNGbEo49Tw==/base.apk"],nativeLibraryDirectories=[/data/app/com.alansar.center-5QLoQbFk5EpZJNGbEo49Tw==/lib/x86, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at org.apache.xmlbeans.XmlBeans.buildStreamToNodeMethod(XmlBeans.java:251)  at org.apache.xmlbeans.XmlBeans.(XmlBeans.java:138)  at org.apache.xmlbeans.XmlBeans.typeLoaderForClassLoader(XmlBeans.java:719)  at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook$Factory.getTypeLoader(Unknown Source:25)  at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook$Factory.newInstance(Unknown Source:0)  at org.apache.poi.xssf.usermodel.XSSFWorkbook.onWorkbookCreate(XSSFWorkbook.java:456)  at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:259)  at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:253)  at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:241)  at com.alansar.center.Mohafez.Fragment.Monthly_Reports_Fragment.onCreateView(Monthly_Reports_Fragment.java:65)  at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)  at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)  at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)  at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)  at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)  at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)  at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)  at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)  at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)  at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)  at android.os.Handler.handleCallback(Handler.java:873)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:6669)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

centic9 commented 4 years ago

It seems you are using an unshaded version of Apache POi, not the one provided in this project. Please make sure your classpath does not contain Apache POI directly as dependency or as transitive dependency in any way.

centic9 commented 4 years ago

Could not reproduce this and update for some time, therefore closing this for now.