android ExceptionInInitializerError由新的HSSFWorkbook(inputStream)无法确定记录类型引起的
作者:互联网
得到错误
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
at java.util.concurrent.FutureTask.run(FutureTask.java:239)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.ExceptionInInitializerError
at b.b.a.c.c.p.<init>(HSSFWorkbook.java:326)
at b.b.a.c.c.p.<init>(HSSFWorkbook.java:289)
at b.b.a.c.c.p.<init>(HSSFWorkbook.java:224)
at b.b.a.c.c.p.<init>(HSSFWorkbook.java:382)
at b.b.a.c.c.p.<init>(HSSFWorkbook.java:364)
at com.d.link.d.d.a(ExportUtils.java:134)
at com.d.link.activity.ey.a(SplashScreen.java:55)
at com.d.link.activity.ey.doInBackground(SplashScreen.java:51)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: b.b.a.c.b.dj: Unable to determine record types
at b.b.a.c.b.dd.a(RecordFactory.java:434)
at b.b.a.c.b.dd.<clinit>(RecordFactory.java:292)
at b.b.a.c.c.p.<init>(HSSFWorkbook.java:326)
at b.b.a.c.c.p.<init>(HSSFWorkbook.java:289)
at b.b.a.c.c.p.<init>(HSSFWorkbook.java:224)
at b.b.a.c.c.p.<init>(HSSFWorkbook.java:382)
at b.b.a.c.c.p.<init>(HSSFWorkbook.java:364)
at com.d.link.d.d.a(ExportUtils.java:134)
at com.d.link.activity.ey.a(SplashScreen.java:55)
at com.d.link.activity.ey.doInBackground(SplashScreen.java:51)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
对于第二行(来自InputStream的新HSSFWorkbook)
FileInputStream fileInS = new FileInputStream(outputXlsFile);
hwb = new HSSFWorkbook(fileInS);
其中org.apache.poi.hssf.usermodel.HSSFWorkbook来自apachePoi库
解决方法:
不能帮助解决为什么会抛出异常,但我可以帮助您阻止应用程序被强制关闭.
该问题与ExceptionInInitializerError类相关联,该类不是由java.lang.Exception派生的.相反,它派生自java.lang.Error超类(参见ExceptionInInitializerError declaration)
因此,解决方案是为此类异常添加显式catch块,例如,以下之一:
catch(ExceptionInInitializerError e) // catch exactly this error
catch(Error e) // catch all Java errors (not exceptions!)
catch(Throwable t) // catch all Java errors and exceptions
请注意,必须将第一个和第二个catch块添加到现有的catch中,而第三个可以替换它们,因为Throwable是Exception和Error Java类的超类.
标签:android,excel,android-library,apache-poi,hssfworkbook 来源: https://codeday.me/bug/20190717/1488206.html