mertakdut / EpubParser

Parses .epub files, provides seperation page by page.
Apache License 2.0
118 stars 27 forks source link

App crash #11

Closed chintandesai49 closed 8 years ago

chintandesai49 commented 8 years ago

App crashes on the version below 19 KitKat but working as expected on version >19 following is the crash report Caused by: java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets at com.github.mertakdut.ContextHelper.encodeToUtf8(ContextHelper.java:26) at com.github.mertakdut.Reader.mergeTocElements(Reader.java:266) at com.github.mertakdut.Reader.fillContent(Reader.java:162) at com.github.mertakdut.Reader.setInfoContent(Reader.java:32) at com.github.epubparsersampleandroidapplication.MenuActivity$ListBookInfoTask.doInBackground(MenuActivity.java:67) at com.github.epubparsersampleandroidapplication.MenuActivity$ListBookInfoTask.doInBackground(MenuActivity.java:50) at android.os.AsyncTask$2.call(AsyncTask.java:287) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:137)  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)  at java.lang.Thread.run(Thread.java:838) 

mertakdut commented 8 years ago

19? What version is that? Api level?

chintandesai49 commented 8 years ago

Yes, API level 19 version name KitKat. And I'm loading epub in webview.

chintandesai49 commented 8 years ago

The problem lies in ContextHelper class where you encode text to UTF-8 with java. But the StandardCharsets class of java is not available below android KitKat version 19.

mertakdut commented 8 years ago

StandardCharsets is available since 1.7. Does Android KitKat use 1.6? Or should you use 1.7 when you are developing your app?

chintandesai49 commented 8 years ago

In KitKat, it is working as expected,but not below the version. So now what is the port to user this library below KitKat version ?

mertakdut commented 8 years ago

I'll check the problem myself and see if I find a reasonable solution. Thanks for the notice.

chintandesai49 commented 8 years ago

I make it work my way but I can tell you that you can make version specific check and put simple condition in ContextHelper class like this. if(version<19) encodedString = URLDecoder.decode(stringToEncode, "UTF_8"); else encodedString = URLDecoder.decode(stringToEncode, StandardCharsets.UTF_8.name());

mertakdut commented 8 years ago

That may not be the only thing that is broken in versions below 19. Is it?

chintandesai49 commented 8 years ago

Yes, I make it work only by putting version specified checking. But you are the author of the library, it's your call to check another condition.

mertakdut commented 8 years ago

The problem is fixed in version 1.0.85, released in few hours. Thanks for your cooperation.