PariDroid
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+).
Installing PariDroid
Ready to use packages in the .apk
format can be found
in the
download section.
They are also available via the
F-Droid
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.
Installing the Android SDK 26.1.1
The following describes our attempts at installing the latest development environment for Android from the command line. Unfortunately, backwards compatibility does not seem to be a concern for the Android SDK developers: We did not manage to run a recent emulator with Android 3 (API 11) images, which is the earliest version for which PariDroid can still be compiled. Also starting the more modern emulator seems to be incredibly slow. So the next chapter, describing how to install the SDK 24.4.1, is still of interest; this is how we currently develop and test PariDroid.
1. SDK
Download the
Android
SDK tools,
for instance the Linux build 4333796, and unpack it into
/usr/local/android-sdk-r26.1.1
(the version 26.1.1 appears in the file package.xml
):
cd /tmp wget http://dl.google.com/android/repository/sdk-tools-linux-4333796.zip mkdir android-sdk-r26.1.1 cd android-sdk-r26.1.1 unzip ../sdk-tools-linux-4333796.zip cd .. su mv android-sdk-r26.1.1 /usr/local
Add the avdmanager
binary to your path,
for instance as symbolic link:
export SDK=/usr/local/android-sdk-r26.1.1 su cd /usr/local/bin ln -s $SDK/tools/bin/avdmanager
Install Android platform tools by downloading and unpacking a software archive as follows:
cd /tmp 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/
Add adb
to your execution path:
su cd /usr/local/bin ln -s $SDK/platform-tools/adb
Install Android build tools by downloading and unpacking a software archive as follows:
cd /tmp 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/29.0.1
Add zipalign
to your execution path:
su cd /usr/local/bin ln -s $SDK/build-tools/29.0.1/zipalign
Install an Android platform by downloading and unpacking a software archive as follows; Android API 11 (Android 3.0) is currently the minimal version required by PariDroid:
cd /tmp wget http://dl.google.com/android/repository/android-3.0_r02.zip unzip android-3.0_r02.zip mkdir $SDK/platforms/ mv android-3.0_r02-linux $SDK/platforms/android-11
The aarch64 architecture appeared for the first time in Android API 21 (Android 5.0); also install this version:
cd /tmp wget http://dl.google.com/android/repository/android-21_r02.zip unzip android-21_r02.zip mv android-5.0.1 $SDK/platforms/android-21
Now we need to download system images for the emulator and install them into the right places; there is one image per Android API and architecture.
For android-11, the system image is already installed
in $SDK/platforms/android-11/images
;
using it to create an avd unfortunately fails.
The only image for aarch64 is android-24; this is also the last one
for arm. From then on, only images for x86 and x86_64 are available.
So android-24 seems like a good choice.
cd /tmp wget http://dl.google.com/android/repository/sys-img/android/armeabi-v7a-24_r07.zip unzip armeabi-v7a-24_r07.zip mkdir -p $SDK/system-images/android-24/default mv armeabi-v7a $SDK/system-images/android-24/default/ wget http://dl.google.com/android/repository/sys-img/android/arm64-v8a-24_r07.zip unzip arm64-v8a-24_r07.zip mv arm64-v8a $SDK/system-images/android-24/default/ wget http://dl.google.com/android/repository/sys-img/android/x86_64-24_r08.zip unzip x86_64-24_r08.zip mv x86_64 $SDK/system-images/android-24/default/
2. Emulator
Download and install the emulator as follows:
cd /tmp wget http://dl.google.com/android/repository/emulator-linux-5839083.zip unzip emulator-linux-5839083.zip mv emulator $SDK/
Add emulator
to your execution path (there are two potential
binaries, one in $SDK/tools
and one in
$SDK/emulator
; the former does not seem to work):
su cd /usr/local/bin ln -s $SDK/emulator/emulator
For the emulator to work, we need to create virtual Android devices (avd), one for each combination of Android API and architecture:
avdmanager create avd -k 'system-images;android-24;default;armeabi-v7a' -n android24-arm avdmanager create avd -k 'system-images;android-24;default;arm64-v8a' -n android24-aarch64 avdmanager create avd -k 'system-images;android-24;default;x86_64' -n android24-x86_64
creates virtual devices for the Android ABI 24 and three different
architectures under the names given after the -n
parameter,
which should be listed when executing
avdmanager list avd
To enable input from the computer keyboard as if it were typed on the
telephone, add to the files
~/.android/avd/android24-arm.avd/config.ini
(and similarly for the other architectures)
the line
hw.keyboard=yes
.
Start the Android emulator with
emulator -avd android24-arm &
A window opens in which (after a few minutes) a telephone screen is simulated. If for simpler testing purposes you can make do without a window, the command
emulator -avd android24-aarch64 -no-audio -no-window &
starts the emulator faster in command line mode. To see whether the emulator is ready, call
adb logcatto see tons of start-up messages. The emulator may be stopped with
adb -s emulator-5554 emu kill
The emulators for the arm or aarch64 architectures recommend to install one for x86, which is supposedly 10 times faster. Unfortunately, the latter refuses to start for lacking hardware acceleration with kvm. The aarch64 emulator loops with error messages.
All in all, there does not seem to be any advantage in switching to the more modern SDK.
Installing the Android SDK 24.4.1
1. SDK
Download the
Android SDK,
for instance the
Linux
build r24.4.1 (which appears to be the last version containing the
tools/ subdirectory and to be independent of Android Studio), and unpack it
into
/usr/local/android-sdk-r24.4.1
:
cd /tmp wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz tar xvf android-sdk_r24.4.1-linux.tgz su mv android-sdk-linux /usr/local/android-sdk-r24.4.1
Add the android
and emulator64-arm
binaries
to your path, for instance as symbolic links:
export SDK=/usr/local/android-sdk-r24.4.1 su cd /usr/local/bin ln -s $SDK/tools/android ln -s $SDK/tools/emulator64-arm
Install Android platform tools by downloading and unpacking a software archive as follows:
cd /tmp 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/
Install Android build tools by downloading and unpacking a software archive as follows:
cd /tmp 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/
The previous steps have populated
$SDK/platform-tools
and
$SDK/build-tools
.
Add adb
and zipalign
to your execution path:
su cd /usr/local/bin ln -s $SDK/platform-tools/adb ln -s $SDK/build-tools/android-10/zipalign
Install an Android platform by downloading and unpacking a software archive as follows:
cd /tmp wget http://dl.google.com/android/repository/android-21_r02.zip unzip android-21_r02.zip mv android-5.0.1 $SDK/platforms/
Now we need to download a system image for the emulator and install it into the right place:
cd /tmp wget http://dl.google.com/android/repository/sys-img/android/armeabi-v7a-21_r04.zip unzip armeabi-v7a-21_r04.zip mkdir $SDK/platforms/android-5.0.1/images mv armeabi-v7a $SDK/platforms/android-5.0.1/images/
2. Emulator
For the emulator to work, we need to create a virtual Android device (avd). First,
android list target
shows one possible target, android-21,
which we have installed previously into
$SDK/platforms
.
android create avd -t android-21 -n android21
now creates a new virtual device with the name android21, which should be listed when executing
android list avd
To enable input from the computer keyboard as if it were typed on the
telephone, add to the file
~/.android/avd/android21.avd/config.ini
the line
hw.keyboard=yes
.
Start the Android emulator with
emulator64-arm -avd android21 &
A window opens in which (after a few minutes) a telephone screen is simulated. If for simpler testing purposes you can make do without a window, the command
emulator64-arm -avd android21 -no-audio -no-window &
starts the emulator faster in command line mode. To see whether the emulator is ready, call
adb get-state
which returns device
when the emulator is ready
(and unknown
before). Or wait until
adb wait-for-device
returns. The emulator may be stopped with
adb -s emulator-5554 emu kill
Installing the Android NDK
To later compile and integrate the PARI C library
into the project, download the
Android
NDK; for instance,
Linux
64bit r13b.
(This is the last version where the include files are still contained in
the platforms/
subdirectory, instead of in sysroot/
.
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
/usr/local/android-ndk-r13b
.
Set the environment variable NDK
to contain the path
to the Android NDK, which is used by our Makefile
:
export NDK=/usr/local/android-ndk-r13b
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-21 -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,
when invoking make
for the first time.
The 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.
The 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 ..
Building PariDroid
A call to
make
configures and compiles the PARI library
and compiles the PariDroid project into
the package PariDroid-VERSION.apk
,
signed with a debug key and aligned.
The unsigned and unaligned package resides in
PariDroid/bin/PariDroid-release-unsigned.apk
,
the signed and unaligned package in
PariDroid/bin/PariDroid-release-unaligned.apk
.
make distclean
removes the generated files. The final package can be tested by installing it in the emulator:
adb install PariDroid-VERSION.apk
After clicking on the application icon on the telephone screen, a click on the PariDroid icon should open the program. To simplify further tests, the icon can be dragged onto the home screen (it will always refer to the latest installed PariDroid instance).
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
adb logcat
in a separate terminal window.