p≡p for Java
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.1 KiB

  1. # Build pEpJNIAdapter for Android
  2. ** Asuming machine is already set up to build pEp Engine and Sequoia! **
  3. ## Install dependencies
  4. ```bash
  5. sudo port -N install gsed wget autoconf automake libtool md5sha1sum openjdk8
  6. ## optionaly (not needed if using Android Studio)
  7. sudo port -N install gradle
  8. ```
  9. ## Install NDK
  10. It can be done with the SDK and the sdkmanager cli tool, or using Android Studio.
  11. Android studio -> Configure -> SDK Manager -> SDK Tools (tab) -> Select NDK and install
  12. Tip: To install other versions click on "Show packages details" and select the desired NDK version (Currently using: 21.0.6113669)
  13. ## Required env\_vars (for MacOS):
  14. ``` bash
  15. export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
  16. export ANDROID_NDK=$ANDROID_SDK/ndk/21.0.6113669
  17. export HOST_TAG=darwin-x86_64
  18. export ANDROID_MIN_SDK_32=18
  19. export ANDROID_MIN_SDK_64=21
  20. export NDK_TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/$HOST_TAG
  21. export PATH=$PATH:ANDROID_NDK/bin
  22. ```
  23. ## Add Rust android targets
  24. ```bash
  25. rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
  26. ```
  27. Tell rust the location of the new target linker and AR
  28. ```bash
  29. echo "
  30. [target.aarch64-linux-android]
  31. ar = \"$NDK_TOOLCHAIN/bin/aarch64-linux-android-ar\"
  32. linker = \"$NDK_TOOLCHAIN/bin/aarch64-linux-android$ANDROID_MIN_SDK_64-clang\"
  33. [target.armv7-linux-androideabi]
  34. ar = \"$NDK_TOOLCHAIN/bin/arm-linux-androideabi-ar\"
  35. linker = \"$NDK_TOOLCHAIN/bin/armv7a-linux-androideabi$ANDROID_MIN_SDK_32-clang\"
  36. [target.x86_64-linux-android]
  37. ar = \"$NDK_TOOLCHAIN/bin/x86_64-linux-android-ar\"
  38. linker = \"$NDK_TOOLCHAIN/bin/x86_64-linux-android$ANDROID_MIN_SDK_64-clang\"
  39. [target.i686-linux-android]
  40. ar = \"$NDK_TOOLCHAIN/bin/i686-linux-android-ar\"
  41. linker = \"$NDK_TOOLCHAIN/bin/i686-linux-android$ANDROID_MIN_SDK_32-clang\"
  42. " >> $HOME/.cargo/config
  43. ```
  44. ## Build it
  45. Open the android project with Android Studio, this will generate the file local.properties with the sdk location.
  46. To build can be done form the Gradle menu (on the right in android studio) and select the build task, or just calling gradle build form terminal.
  47. ``` Bash
  48. gradle build #Run inside JNIAdapter/android
  49. ```