This was posted on MSE originally.

Please note that my only training in programming of any kind is in the context of mathematics, specifically group theory. Thus, please use minimal technical language.

The Problem:

I'm trying to get GAP on my Android phone.

(I'm using a ZTE Blade V8. I doubt that matters.

Update: I'm using a Samsung Galaxy A40 these days.)

What I have so far:

I found on the GAP forum that someone called Matan Ziv-Av compiled a version of GAP for Android that can be found here (and more specifically here).

This explains something I don't understand.

I have downloaded the latest file, last updated in 2015 (so it's gap4r6), but, upon opening it with RAR, I have been unable thus far to run the programme.

Here is a screenshot of the file I think I need to click on to get started:

(Click image to enlarge it)


I can't seem to get it working.

Please help :)


Using Termux with the file in the screenshot above, I got this:

(Click image to enlarge it)


  • The original MSE question.
    – Shaun
    Oct 30, 2018 at 4:15
  • Have you tried installing Terminal Emulator for Android or Termux? Based on the announcement link you should be able to install either and get a Linux like environment to run your package. Of course perhaps a required step is to understand how to get around in Linux/Unix, your level of ability on that point is unclear. Oct 30, 2018 at 5:28
  • @MorrisonChang I've tried the former, no luck there - uninstalled. I'm downloading the latter now.
    – Shaun
    Oct 30, 2018 at 5:33
  • 1
    Sorry don't know Termux, but this seems related: Where is the folder that Termux defaults to?. Another path could be to install your 'GAP' software on a regular PC running Linux and use an Android SSH client to remote into it, you'll need to have a network connection to make that work. Either way you'll need to have an understanding of Linux command line even if you got GAP on Android working. Nov 5, 2018 at 5:08
  • 1
    @Shaun do you always get that getprop message when opening termux? That indicates that something went wrong during the app installation (or that something is weird on your phone). Could you try reinstalling the app and opening termux again to see if it persists? This github issue (sort of) describes the error: github.com/termux/termux-app/issues/849
    – user155804
    Nov 14, 2018 at 15:31

3 Answers 3


2023-08 Update

Only use Termux from F-Droid or the github repository as the version from Google Play store is no longer supported.

Be aware that Termux may be unstable on Android 12+, as Android OS will kill any (phantom) processes greater than 32 (limit is for all apps combined) and also kill any processes using excessive CPU. See README section for details and links to workarounds

0. Uninstall Google Play Store Termux

  • If Termux was installed from Google Play Store, save important data off of device. (If you don't have any important data, skip this step).
  • Delete the Google Play Store version of Termux

1. Install F-Droid

When Termux updates, it will be easier to manage from F-Droid so first install F-Droid

  • In your mobile browser go to https://f-droid.org/
  • Click on "Download F-Droid"
  • Install F-Droid by clicking on the downloaded package. Note if Android prompts you to "Open with", choose 'Package installer'

If you are having difficulty installing F-Droid, follow Step 2 to see if your browser is enabled to "Install Unknown Apps" and allow.

2. Give Install permission to F-Droid

  • Go into Settings -> Search (magnifying glass icon)
  • In search bar type in "Install Unknown Apps"
  • Tap on "Install unknown apps Apps > Special app access"
  • On the "Special access" / "Special app access" screen scroll down to "Install unknown apps" and click
  • On the "Install unknown apps" screen look for F-Droid and click
  • For the "F-Droid" app, enable "Allow from this source"

3. Install Termux from F-Droid

  • Open F-Droid
  • Tap the green search action button in the lower right.
  • Type in "Termux"
  • Tap on the one that reads "Termux Terminal emulator with packages" Note on the app store page there should be 'Versions' expandable which should have 0.118.0 or higher.
  • Install Termux

You should now have Termux in your list of available apps.

4. Launching and upgrading Termux packages

  • Launch Termux

Linux distributions support package management so the easiest way to install is via a package manager. Termux uses one as well which is documented in the wiki. Following the wiki use the command highlighted in grey:

  • $pkg upgrade

Answer with 'Yes' to upgrades unless there is a known conflict with an existing installed package.

4a. Check if the software package already exists

As building from source takes storage space and knowledge it is best to check if what you are looking for already exists as a package.

Running the command in Termux:

  • $pkg search gap

Listed out

gap/stable 4.12.2 aarch64

Gap is a system for computational discrete algebra, with particular emphasis on Computational Group Theory

gap-packages/stable 4.12.2 all

Packages for gap

gap-static/stable 4.12.2 aarch64

Static libraries for gap

5. Install software package

Run the command

  • $pkg install gap

and enter 'Yes' you want to install. Should install gap at a cost of around 204 MB.

6. Run software package

Run gap as in other Linux/Unix-like environments

  • $gap

7. Leave Termux

Termux when you swipe away will maintain the session and have a status bar notification telling the user that it is still running to keep its state.

Removing the notification requires stopping Termux from running. To end Termux just execute

  • $exit


Termux behaves similar to a Linux/Unix-like system but out of the box you are limited to storing things within Termux app itself.

Do check the Termux Wiki to get familiar. If needed there are other Development environments available for Termux.


This is how I got it to run.

I'm using the download from here GAP for Android

Preparations: In termux type termux-setup-storage when prompted to give termux storage permission select allow. This is to give access to the sdcard in termux.

  1. Make sure your connected to the internet.
  2. In termux, type pkg install wget press enter.
  3. Now to download the file type wget my.svgalib.org/android/gap4r5-1.tar.gz then hit enter.

  4. Extract the file type tar -zxf gap4r5-1.tar.gz hit enter.

  5. Type cd gap4r5 hit enter.

  6. Now we need to make a couple of changes to the script for it to run on termux. We will copy it to the sdcard Download file to be able to edit it. type cp gap.sh /storage/emulated/0/Download/ hit enter.

  7. Now open the file gap.sh in a text editor, I used Notepad++ for Android. This file is in your Download folder.

  8. Edit line #1 to look like this #!/data/data/com.termux/files/usr/bin/bash

  9. Edit line #23 to look like this GAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" Its very important on this line to have the spaces exactly where they are and nowhere else. then save the file. (Thanks for this line goes to Dave Dopson at this post Getting the source directory of a Bash script from within )

  10. Go back to termux and type cp /storage/emulated/0/Download/gap.sh . (the period at the end is important) and hit enter.

  11. Now you are ready to start using the program. to run the program make sure you are in the folder gap4r5 and type ./gap.sh. (To get to this folder when you start termux type cd gap4r5 or wherever you are in termux type cd hit enter and type cd gap4r5 and hit enter).

Good Luck!

  • I couldn't do step 6. My phone denied Termux the permission to execute the demand.
    – Shaun
    Jan 11, 2019 at 12:43
  • 1
    Did you run termux-setup-storage and give termux the permission?
    – Sruly
    Jan 11, 2019 at 14:00
  • I did, and I've tried it multiple times since that. It hasn't worked, I'm afraid. See this image where I get stuck on part 4. I'm sorry that this is taking me so long. (In my defence, I haven't been trying this out much over the last few weeks.)
    – Shaun
    Feb 27, 2019 at 22:10
  • From the error message it seems there may be something wrong with the tar file. Can you try re-downloading the file (step #3) again.
    – Sruly
    Feb 28, 2019 at 22:08
  • @Shaun Check the MD5 hash of the file and make sure it matches this "12CC0203386FB891D9DDCA86222797FD". If not try re-downloading the file (step #3) again.
    – Sruly
    Feb 28, 2019 at 22:21

Since GAP is open-source you can download the sources and compile them on device in termux or another terminal emulator (though other terminal emulators don't provide the compilation tools AFAIK).

There are quite detailed compilation instructions in the "README.buildsys.md" file in the gap source directory, have a look at that for some more details. Here are the steps I did to compile it (after opening a termux shell), lines starting with "#" are comments and are hence suppose to help you understand what the following line(s) does.

# Install programs needed to compile gap
pkg install make clang m4
# Install some optional dependencies that probably enhance your gap experience
apt install readline-dev libgmp-dev
# Download sources
wget https://www.gap-system.org/pub/gap/gap-4.10/tar.gz/gap-4.10.0.tar.gz
# Extract sources and change to that folder
tar -xf gap-4.10.0
cd gap-4.10.0
# Create a build folder to keep source directory clean
mkdir build
cd build
# Configure the package, if you want special features you probably want to change this line
# Compile the package
# Run GAP!

Please let me know if you run into any errors (I might have missed some dependencies) or if I should explain something in more details. Also note that you have to compile and run gap from termux's folder structure (/data/data/com.termux/files/), android doesn't allow executable files in the shared storage (like the external and internal sdcard).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .