readium / readium-sdk

A C++ ePub renderer SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to import and compile readium Android to my own project

hellcan opened this issue · comments

Hi there,

what is the step to import and compile readium android SDK to my own project?

Please use the Android ReadiumSDK "launcher" app as your "template" (examplar demo):
https://github.com/readium/SDKLauncher-Android/tree/develop
You will find the necessary Gradle configs etc. to get you started.

guys is there anyway you can make it easier to compile it in our own projects...i dont know maybe a documentation on how to do that ? its too difficult to implement sorry for bothering but im having a hard time integrating to my app

The use of the readium sdk on android has been until now in the hands of developers of white label reading apps. The android ecosystem (android studio, ndk and blink) has evolve very fast, and getting a documentation that covers the multiple layers of evolution is a challenge.

It appears that the sample app called "launcher" is not enough for many implementers. The Readium Foundation wants to create a usage guide for a recent version of android studio / ndk, but will certainly need some help from different implementers to get it right.

i understand that it is a bit challenging to make the documentation..but the SDKLauncher is messy and makes no sense for implementation you guys could at least give us a step by step on how to navigate inside de sdk launcher app.

sorry if im being presumptuous but i've been trying for two days straight to compile this to my project unsuccessfully.

We're sorry you are having problems. Perhaps if you could detail the problems you see "we" could help. But to be clear, Readium is an open-source effort. There is no staff or development group. Which is part of the reason the documentation sucks - none of the developers or white-label groups wanted (or were able to) take the time.

i understand completely...and again i apologize if im being harsh, i just cant get it to compile to use de lib i import the project but cant transform it in a lib and is it really necessary to have all those build gradles?

i now import the module and i got the lib but it keeps generating an error cant find epub3:buildMk and it doesnt import the classes from the project such as SpineItems

screen shot 2017-10-25 at 16 50 27

screen shot 2017-10-25 at 16 50 37

as you can see the module is already compiled but its not being accepted by the IDE therefore i cant use it

Just out of interest: what is your motivation (eg. DRM, performance?) for using a native lib written in C++ for loading and parsing EPUB files from your Java app? Note that the code module that implements most of the layout + rendering logic is written in JavaScript (readium-shared-js), and there are hybrid app implementors who go as far as using readium-js to avoid writing a parser from scratch.

my product is already developed as a native app since we found readium to be the lib the accept the most customization we are trying to implement it in our app i could use folioReader that already uses readium2 put it only has vertical scroll and i need to be horizontal

any takers on why i cant seem to find the classe SpineItem?

I suspect your Java app code cannot find the native JNI / NDK lib. Are you able to successfully compile and run the Readium SDK Android launcher app, using Gradle experimental or stable as defined in your local.properties? If this doesn't work as a starting point, then some of us might be able to help. Conversely, if this works, then we know the problem stems from your app's configuration, and we can debug from there.

screen shot 2017-10-26 at 13 53 23

so here is everything i've done so far i imported the modules properly i name
d as JAVA lib and the epub3 folder. it works and compiles..i didnt have to do anything on local.properties because it synced automatically

screen shot 2017-10-26 at 13 55 44

as you can see on the screenshot the ork.readium.sdk.android is compiled and it should work but everytime e try to use a class it tells me to add as a dependendcy to my project

screen shot 2017-10-26 at 13 57 28

but i have already done that

Could you please confirm whether or not you are able to compile and run (i.e. launch the app on your phone or emulator) using the Android Studio project from the SDKLauncher-Android subfolder (https://github.com/readium/SDKLauncher-Android/tree/develop/SDKLauncher-Android), excluding the Readium_SDK_Test_Android subfolder (https://github.com/readium/SDKLauncher-Android/tree/develop/Readium_SDK_Test_Android).

Also, please edit your local.properties and make sure to enable Gradle "experimental" which will build readium-sdk in such a way that you will be able to debug into hybrid Java/C++ code (which will help you debunk your app-specific issues when integrating with the native JNI API).

readium.ndk_experimental=true

Other useful settings, to save time by only compiling ARM (device) or X86 (emulator):

readium.ndk_skipX86=true
readium.ndk_skipARM=false

i can run the SDKLauncher after i put this line of code
readium.ndk_experimental=true
readium.ndk_clang=false
readium.ndk_skipARM=false
readium.ndk_skipX86=true

the problem is to start a project from scretch import de module and to know all the files i have to change to make it work

im my app i keep getting this abort . Stop

Error:Execution failed for task ':epub3:buildMk'.

Process 'command '/Users/blennersilva/Library/Android/sdk/ndk-bundle/ndk-build'' finished with non-zero exit value 2

screen shot 2017-10-26 at 16 11 09

In the interim, you can comment the Gradle line that calls
build_EpubReadingSystem.gradle
and see if it helps.
If it does, then there is some kind of problem with shell commands and/or the Git subsystem on your machine configuration.
Skipping the "epubReadingSystem" script means not preparing the script that injects marching versioning information in your application build. It is a "nice to have" feature, but not critical. You should be able to use your app without any issues.

PS: if the compile process stops at the ndk-build command, then it is an issue with the underlying NDK, so please report your ndk-bundle version (see the Android Studio platform updates / SDK manager)

I comment all the epubReadingSystem usage first
image
Then my android studio shows
image
After that i comment epub3:buildMk
image
Then i find out armeabi-v7a and x86 folder under epub3 are empty!
image

When I am trying to run my project , AS shows that
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.ding.reader.noveltreaderapp-1/base.apk", zip file ......,nativeLibraryDirectories=[/data/app/com.ding.reader.novelreaderapp-1/lib/x86, /vendor/lib, /system/lib]]] couldn't find "libepub3.so"
and
image
So i can't use epub3 module

finally i copy paste these 4 files from SDKLuancher-Android template manually
image

Now my project build successful and I can use epub3 module in my own project

But what should i do to make epub3:buildMk work? So i don't need do the copy paste thing
this is the buildMk code
image

Thank you

The epub3:buildMk Gradle task starts because you are not using readium.ndk_experimental=true in your local.properties (and as a result, the low-level NDK command line is invoked, usually ndk-build.sh located in the Android SDK platform (i.e. Android Studio -managed ndk-bundle, probably v14 or v15 depending on how up to date your IDE is)).
What is your NDK version?

Also, have you tried compiling with readium.ndk_experimental=true so that ndk-build.sh is not invoked directly?

My NDK version
image

My project build successful after I add readium.ndk_experimental=true in local.properties

Now I can imported and compile readium android SDK into my own project successful after comment build_epubReadingSystem.gradle

Thank you for your help

Good news. Sorry for the trouble, but Google updated the recommended JNI / NDK build process several times (ndk-buils.sh, Gradle NDK DSL, Cmake) ... and things will change again when NDK officially deprecates GCC in favour of CLANG (although in this case I think the ReadiumSDK will stick to the latest available version of NDK that supports GCC, the maintenance costs at each update are too high, for too few benefits, IMO)

hi,
is there a gradle lib to import and use? everything seems complex