readium / SDKLauncher-Android

Launcher app for Readium SDK on Android
BSD 3-Clause "New" or "Revised" License
77 stars 65 forks source link

App is crashing at Android 5.0 device while loading a eBook #144

Open nareshsvn opened 6 years ago

nareshsvn commented 6 years ago

Hi There,

Is epub3 sdk supports Android 5.0 ? The reason is we are Facing a issue while loading epub3 lib on some devices with Android 5.0. The error happens particular on device with Android 5.0 otherwise it works perfectly on device with higher android OS.

Environment Details:

Android Studio version: 3.1.2 Android version: 5.0 Lollipop NDK VERSION: 15rc Device Model: Lenovo A-2010 a

Code of reference:

static { // Load the ePub3 Native lib System.loadLibrary("epub3"); // In this line causing the crash. }

Crash Log:

ssl=0x9f61d600 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA 06-21 15:36:29.494 16436-16436/ E/art: dlopen("/data/app//lib/arm/libepub3.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "_ZTVN10cxxabiv117class_type_infoE" referenced by "libepub3.so"... 06-21 15:36:29.822 16436-16436/E/AndroidRuntime: FATAL EXCEPTION: main Process: , PID: 16436 java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread. at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:59) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5624) 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:959) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZTVN10cxxabiv117class_type_infoE" referenced by "libepub3.so"... at java.lang.Runtime.loadLibrary(Runtime.java:371) at java.lang.System.loadLibrary(System.java:988) at org.readium.sdk.android.EPub3.(EPub3.java:44) at .MyLoansFragment.openBook(MyFragment.java:512) at .MyLoansFragment.onBookAvailableToRead(MyFragment.java:499) at ulipresenter.MyLoansPresenter$10.onNext(MyPresenter.java:301) at .MyLoansPresenter$10.onNext(MyPresenter.java:285) at rx.internal.util.ObserverSubscriber.onNext(ObserverSubscriber.java:34) at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:134) at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.call(OperatorObserveOn.java:224) at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5624) 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:959) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) 06-21 15:36:30.504 16436-16471/E/NativeCrypto: ssl=0xaf840800 cert_verify_callback x509_store_ctx=0xa203a1b0 arg=0x0 ssl=0xaf840800 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA

danielweck commented 6 years ago

I think this is an STL bug. Maybe -DANDROID_STL=c++_shared can help (?) With the Gradle experimental plugin: https://github.com/readium/readium-sdk/blob/develop/Platform/Android/epub3/build_experimental.gradle#L125

With the Gradle stable plugin: https://github.com/readium/readium-sdk/blob/develop/Platform/Android/epub3/build.gradle#L140 https://github.com/readium/readium-sdk/blob/develop/Platform/Android/epub3/Stable.mk#L154

Note that this is with GCC, not Clang (only the former is supported in ReadiumSDK, even though the latter will gradually officially supercedes the former in NDK)

danielweck commented 6 years ago

Yes, this is in fact an issue with "vtable for cxxabiv1::class_type_info", which requires -lstdc++ (maybe use g++ instead of gcc ... but I'm not sure what to change in the NDK makefile / Gradle build scripts)

danielweck commented 6 years ago

http://demangler.com

_ZTVN10__cxxabiv117__class_type_infoE => vtable for __cxxabiv1::__class_type_info

danielweck commented 6 years ago

A quick web search seem to confirm that -DANDROID_STL=c++_shared is needed in the NDK build script (Gradle or Makefile). Could you please try? Many thanks!

nareshsvn commented 6 years ago

-DANDROID_STL=c++_shared - I have added this flag in android.mk as well as in the gradle of epub3 project but i am getting similar error. Could you please elaborate on how to add this flag ? On the main GitHub project it is written that the android library is build using GCC 4.7 and 8re version of NDK. If i have to change to G++ do i have to build the entire project using g++ and then include the libraries in the android project ?

Please let me know.

Thanks

danielweck commented 6 years ago

I am afraid I personally do not have the necessary experience / expertise to help solve this problem in a timely manner. I am certainly concerned that a separate build config would be needed specifically for a particular Android version (or combination of device hardware / software) :(