PariDroid is a port of PARI/GP to Android, started by Charles Boyd and currently maintained by Andreas Enge and Laurent Facq. It is distributed under the GNU General Public License, either version 3 of the licence, or (at your option) any later version (GPLv3+).
Ready to use packages in the
.apk format can be found
They are also available via the
and the Google Play stores. The remainder of this page describes how to
compile the source code for yourself; there is no need to do so if you are
happy with the provided binaries.
PariDroid manipulates no personal data.
Règles de Confidentialité
PariDroid ne manipule aucune donnée personnelle.
Installing a command line development environment
The following section describes how to set up a reproducible environment
in which to compile PariDroid from the command line. This is how we
currently produce the
.apk package for distribution on a
headless server. Instead of using an emulator, we directly test on a
Installing the Android SDK 24.4.1
This is the last SDK version that contains the necessary files for building
with Ant, in particular the
tools/ subdirectory with the files
SDK r24.4.1 and unpack it into
mkdir -p $HOME/local/bin cd $HOME/local wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz -O - | tar zx mv android-sdk-linux android-sdk-r24.4.1
$HOME/local/bin to your path, for instance by executing
Make a symbolic link to the
export SDK=$HOME/local/android-sdk-r24.4.1 ln -s $SDK/tools/android bin/
Install Android platform tools by downloading and unpacking a software archive as follows:
wget http://dl.google.com/android/repository/platform-tools_r29.0.1-linux.zip unzip platform-tools_r29.0.1-linux.zip mv platform-tools $SDK/ rm -f platform-tools_r29.0.1-linux.zip
Install Android build tools by downloading and unpacking a software archive as follows:
wget http://dl.google.com/android/repository/build-tools_r29.0.1-linux.zip unzip build-tools_r29.0.1-linux.zip mkdir $SDK/build-tools mv android-10 $SDK/build-tools/ rm -f build-tools_r29.0.1-linux.zip
The previous steps have populated
ln -s $SDK/platform-tools/adb bin/ ln -s $SDK/build-tools/android-10/zipalign bin/ ln -s $SDK/build-tools/android-10/apksigner bin/
Install an Android platform by downloading and unpacking a software archive as follows:
wget http://dl.google.com/android/repository/android-19_r04.zip unzip android-19_r04.zip mkdir $SDK/platforms mv android-4.4.2 $SDK/platforms/ rm -f android-19_r04.zip
Installing the Android NDK
To later compile and integrate the PARI C library
into the project, download the
NDK; for instance,
(This is the last version where the include files are still contained in
platforms/ subdirectory, instead of in
Version r17c is the last version that ships the GCC cross compiler.
Version r18b contains a compiler named gcc, but which in reality is clang.)
Unpack it and move it, for instance, to
cd $HOME/local wget https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip unzip android-ndk-r13b-linux-x86_64.zip rm -f android-ndk-r13b-linux-x86_64.zip
Set the environment variable
NDK to contain the path
to the Android NDK, which is used by our
Setting up the PariDroid project
The following steps need to be executed only once. Download PariDroid from its git repository:
git clone http://pari.math.u-bordeaux.fr/git/paridroid.git cd paridroid/PariDroid
Prepare the Android project:
android update project --target android-19 -s -p . cd ..
The PARI source code will be fetched automatically
from the git server and placed into the
../srclib/pari directory, next to the PariDroid sources,
make for the first time.
Makefile also contains the logic to check out the
correct PARI version depending on the PariDroid version number:
its first three fields specify the PARI version.
If it corresponds to a released version, the corresponding git tag
is checked out. Otherwise, the latest git master is fetched.
Makefile is set up to create an apk in release mode,
which is then signed with a debug key. On the first run, this key needs
to be created by doing a debug build:
cd PariDroid ant debug cd ..
A call to
configures and compiles the GMP and PARI libraries
and compiles the PariDroid project into
signed with a debug key and aligned.
The unsigned and unaligned package resides in
the signed and unaligned package in
Once the libraries have been compiled, it is faster to only call
to run the NDK and Android builds on a potentially changed PariDroid code.
removes the generated files. The final package can be tested by installing it in a device that is connected by USB in debug mode:
adb install PariDroid-VERSION.apk
The package can be uninstalled using
adb uninstall fr.ubordeaux.math.paridroid
or, more easily, an installed package can be overwritten with
adb install -r PariDroid-VERSION.apk
For debugging purposes, it may be useful to launch the command
in a separate terminal window.
Installing Android Studio on GNU Guix
Installing Android Studio entails a certain loss of reproducibility: It consists essentially of running an install script, that directly afterwards downloads the actual software and later continuously downloads further updates to an ever shifting environment. On the positive side, the integrated development environment and emulator ease the Android development process. While purportedly being free software, Android Studio is delivered as opaque binaries with hard-coded execution paths, which makes it difficult to deploy on GNU/Linux distributions that are not compliant with the file system hierarchy.
Installing Android Studio
I chose to install everything Android into
$HOME/Android. Unless told otherwise, Android Studio downloads
everything related to the SDK and the NDK into
$HOME/Android/Sdk, and I downloaded and unpacked
$HOME/Android/Studio; in particular, the launcher script
Then I prepared an environment containing the dependencies (that is,
essentially, the dynamic libraries to which the Android Studio binaries
expect to link) in the following file
(use-package-modules base bash compression gcc gl glib linux nss pulseaudio version-control virtualization xml xorg java file) (packages->manifest (list bash git which dbus (list gcc "lib") coreutils grep sed findutils xmessage (list openjdk14 "jdk") file glibc ;; for running the android virtual devices (AVD): e2fsprogs qemu-minimal alsa-lib expat libxcomposite libxcursor libxi libxtst mesa nss pulseaudio (list util-linux "lib") libx11 zlib))
Compared to Julien's environment, I added the
openjdk package at version 14 (the most recent version
available in Guix at the time of writing), which
automatically provides the environment with the corresponding
javac and other executables.
I also added
glibc for debugging
purposes: In particular
ldd of the
package helps to distinguish binaries for 32-bit architectures (that do
not run on Guix) from those for 64-bit architectures (which may run).
(Additionally I had the impression that
glibc was needed
to link with some of the binaries, but later tests seem to imply that
it is not actually needed.)
xmessage provide binaries that
studio.sh looks for in its first few lines.
On my machine, I also had to enable virtualisation support in the BIOS
to be able to run the emulator; otherwise the corresponding kernel module
would not be loaded and
/dev/kvm would be absent from the
The next step is to create the environment and memorise its location, to be able to pass some directories it contains to the actual later invocation:
cd $HOME export PROFILE=$(guix environment -C -N -m $HOME/Android/studio-manifest.scm \ -- bash -c 'echo $GUIX_ENVIRONMENT')
Now the environment variable
$PROFILE contains something like
/gnu/store/f994jk1i9g7lmf3zh5dak92hcimgw91r-profile with its
lib and so on
Then the environment is created in a container (
network access (
guix environment -C -N --share=$XAUTHORITY --share=/tmp/.X11-unix \ --share=/dev/shm --expose=/etc/machine-id --expose=$HOME \ --expose=$PROFILE/lib=/lib --expose=$PROFILE/lib=/lib64 \ --expose=$PROFILE/bin/bash=/bin/bash \ --share=/dev/kvm -m $HOME/Android/studio-manifest.scm
Parts of the surrounding system are passed into the container, as well
lib64 subdirectories of the
profile, which inside the container are accessible as
/lib64; this is the magic that makes the hard-coded
paths in Android Studio work. Additionally to Julien's invocation, I had
to pass in
/bin/bash as well to be able to use the
For reasons probably related to containers and that I do not know, it is
important to carry out the
cd $HOME as given above before
entering the container; otherwise upon starting Android Studio complains
that the directory
$HOME/.config/Google/AndroidStudio4.1/ is read-only.
If everything goes well, the container is entered, which can be seen from
the prompt being changed to
Julien succeeded in calling
env upon entering the container,
which made it possible to pass environment variables in; for unknown
reasons this did not work for me. So I recorded the content of the
outside the container; the first commands in the container set
these variables to the same values, and also set
To avoid that the C compiler from the NDK includes incompatible header
files from the Guix
glibc passed into the environment, we also
need to forget
export XAUTHORITY=/run/user/1001/gdm/Xauthority export DISPLAY=:1.0 export LD_LIBRARY_PATH=/lib:/lib/nss:$HOME/Android/Sdk/emulator/lib64/qt/lib:$HOME/Android/Sdk/emulator/lib64 unset C_INCLUDE_PATH
Finally Android Studio can be started, and from there on it does its business of downloading things and setting them up:
After downloading the SDK, Android Studio complained about something
related to SD cards. It turns out there was a conflict between binaries
for 32- and 64-bit architectures. So I removed the 32-bit binary
and replaced it by a symbolic link to
A similar looking problem still persists: After each start, Android Studio
complains that file watcher failed to start; but here removing
and replacing it by a symlink to
did not solve the problem.
Setting up the PariDroid project
Here I cheated and simply copied the manually set up project to
$HOME/Android/paridroid; then the subdirectory
can be opened as a project in Android Studio.
$HOME/Android/Project/paridroid/ is a
git checkout of the project sources (together with a few local files,
see below), so one may easily change branches or make modifications
in Android Studio and commit them to the git repository.
make (more precisely,
make pari) once
$HOME/Android/paridroid may be necessary to
pari libraries for the
different architectures and to place them into the architecture-specific