readium / readium-sdk

A C++ ePub renderer SDK
BSD 3-Clause "New" or "Revised" License
388 stars 164 forks source link

Various Android / Gradle updates (current working build) #317

Open danielweck opened 5 years ago

danielweck commented 5 years ago

Upgraded API 26 to 28, build tools to 28.0.3, Gradle 5.4.1, max processors / thread 6 (native NDK compiler). NDK is version 16.1.4479499: https://github.com/android/ndk/wiki/Unsupported-Downloads#r16b https://developer.android.com/ndk/downloads/older_releases#ndk-16b-downloads

Notes:

platform/android/local.properties

(not checked into Git, must be created by developers)

sdk.dir=/PATH_TO/Android/sdk
ndk.dir=/PATH_TO/Android/sdk/ndk-bundle-old
readium.ndk_clang=false
readium.ndk_skipX86=false
readium.ndk_skipARM=false
readium.ndk_experimental=false

Note that AndroidStudio ships with the most recent ndk-bundle (version 18+), but ReadiumSDK requires version 16-b (which I downloaded into the sibling ndk-bundle-old folder).

gradle-wrapper.properties

When using the Gradle "experimental" plugin (as configured in local.properties, see above), Platform/Android/gradle/wrapper/gradle-wrapper.properties must be edited to change from version 5.4.1 to 3.3.

Java versions

OpenJDK 12 is now compatible with the latest Gradle (11 was broken due to missing private-API / proprietary libraries which are not available by default anymore). For the Gradle experimental plugin I still have to install JDK 1.8. On MacOS, I actually have the legacy version 1.6 as well: ls /Library/Java/JavaVirtualMachines/ ==>

1.6.0.jdk
jdk-11.0.1.jdk
jdk-12.0.1.jdk
jdk1.8.0_202.jdk

...and my shell configuration looks like: cat ~/.bash_profile ==>

export JAVA_HOME="$(/usr/libexec/java_home -v 11)"
export PATH=/PATH_TO/Android/sdk/platform-tools:$PATH

...so I just invoke this shell command in order to switch to the compatible Java runtime: export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)" && java -version ==>

java version "1.8.0_202-ea"
Java(TM) SE Runtime Environment (build 1.8.0_202-ea-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b03, mixed mode)

Build output

When invoking gradlew assembleDebug, a successful build output libs into the Platform/Android/epub3/libs/ folder (armeabi-v7a and x86 subfolders). However, compiling the readium-lcp-client lib requires adding DEBUG and RELEASE folders in order to differentiate the build flavours. So I create these folders manually and copy the files across.

Hopefully this will help someone else :)

danielweck commented 5 years ago

TODO: the references to the bintray repository should probably be updated in order to reflect the latest available versions, for example:

https://bintray.com/android/android-tools/com.android.tools.build.gradle/view (2.3.3)

vs.

https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google (3.x)

...and:

https://bintray.com/android/android-tools/com.android.tools.build.gradle-experimental/view (0.9.3)

vs.

https://mvnrepository.com/artifact/com.android.tools.build/gradle-experimental?repo=google (0.11)

Also see: https://developer.android.com/studio/releases/gradle-plugin

danielweck commented 5 years ago

64 bits guide: https://developer.android.com/distribute/best-practices/develop/64-bit

Gradle experimental tips: http://tools.android.com/tech-docs/new-build-system/gradle-experimental

aviashiet commented 5 years ago

Getting below error - ndk-bundle/ndk-build'' finished with non-zero exit value

danielweck commented 5 years ago

@aviashiet have you followed the instructions at the top of this PR? Are you using the exact same versions?

aviashiet commented 5 years ago

@danielweck -Yes i am using -https://github.com/readium/readium-sdk/tree/feature/latest-working-build-config

Now getting below error - Cause: org.jetbrains.plugins.gradle.tooling.util.ModuleComponentIdentifierImpl.getModuleIdentifier()Lorg/gradle/api/artifacts/ModuleIdentifier;

danielweck commented 5 years ago

What are the actual installed versions in your command line? (NDK, Java, Gradle, etc.)

aviashiet commented 5 years ago

@danielweck - Now i can made 64 bit .so file ,Thanks a lot Daniel