Skip to content

Quick scripted compilation of Libsodium for Android

License

Notifications You must be signed in to change notification settings

wavemm/Robosodium

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lincoln's updated building instructions

On an Ubuntu machine, run

  • ./install_software.sh
  • sudo update-alternatives --config java and choose jdk 8
  • ./download_ndk.sh
  • ./build_android_libsodium.sh
  • cd jni && ./install_swig.sh (runs a sudo make install, fyi)
  • ./build_jni.sh

This should output into libs a bunch of .so files. You need to copy them into the monorepo as such, as well as the SodiumJNI file:

  • export MONOREPO=~/w/monorepo (edit this path)
  • cp -r libs/* $MONOREPO/android/lib/src/main/jniLibs/
  • cp src/main/java/org/abstractj/kalium/SodiumJNI.java $MONOREPO/android/lib/src/main/java/org/abstractj/kalium/

What I did to bring this into Wave's codebase was to vendor all the Java files, but pre-compile the native library on my machine, because I didn't want to do an ndk build process for our whole team.

To change the functions exported to the JNI, edit jni/sodium.i.

Below is the original readme.


Robosodium

Robosodium was born as a fork of kalium-jni. With this library you will be able to compile libsodium for Android platforms and automatically create the wrapper for the JNI.

Credits to:

How to

  1. First of all download this repository and its submodules:
$ git clone https://github.com/GerardSoleCa/Robosodium
$ git submodule init 
$ git submodule update
  1. Start from first clone:
$ ./do_the_job.sh
  1. Build JNI for Linux instead of Android:
$ ./do_the_job.sh linux
  1. Where to find the compiled libs:
cd libs # Libs for Android using the architecture dirs
cd linux_lib # Lib for Linux. To be used copy to /usr/lib for example. Or just place anywhere you want
  1. If something goes wrong or you want to run again some parts of the compilation, just call the following scripts:
do_the_job.sh # Start and run all the scripts
install_software.sh # First update aptitude cache and install necessary packages
build_jni_linux.sh # Build libsodium with jni for linux.
download_ndk.sh # Download the required Android NDK
build_android_libsodium.sh # Compile Libsodium for Android
build_jni.sh # Generate the JNI library (*.so)

Build AAR

On Linux, simply run:

$ ./build_aar

On OS X, ensure that you have SWIG, Android SDK and NDK installed, and your JAVA_HOME, ANDROID_HOME, ANDROID_NDK_HOME set, then run:

$ ./build_aar_osx

License

Each part has its own software license, including:

About

Quick scripted compilation of Libsodium for Android

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 77.5%
  • Shell 17.8%
  • Makefile 4.7%