HOWTO Build the Nextcloud App using the CLI

In the past week, I searched how to build the Nextcloud App only from the CLI but did not find. The solutions I found used Android Studio, which I find a little heavy. So I decided to build it with fdroid and share my experience.


All along this tutorial, I will be using the following docker image
If you want to install docker for your system see

Download the image sudo docker pull runmymind/docker-android-sdk
Run the image sudo docker run -it -v/your/working/directory/android:/data runmymind/docker-android-sdk /bin/bash
Where /your/working/directory/android could be for example /home/michel/Projects/android

Debug mode

Building the app in debug mode is the easiest way to build the app

  • cd /data
  • git clone --recursive to clone the repo
  • cd android
  • ./gradlew assembleDebug to build it

Your apk file will be located in build/outputs/apk/debug/

Release mode | EDIT : The following part is useless please see the other section

The release mode is much more complicated due to some Google Service
dependencies. The recommended way to build it is with Android Studio 3, if you
try with gradle you will have the same problems as specified here

  • cd /data
  • git clone
  • git clone && export PATH=$PATH:/data/fdroidserver to install the last fdroid version
  • wget
  • unzip && export PATH=$PATH:/data/gradle-4.7/bin to install the last gradle version
  • apt-get install aapt adb android-libaapt android-libadb android-libandroidfw android-libbacktrace android-libbase android-libcutils android-liblog android-libunwind android-libutils android-libziparchive android-sdk-platform-tools-common default-jdk-headless default-jre-headless dh-python libccid libpopt0 libprotobuf-lite10 libpython3-stdlib libusb-1.0-0 libwebp6 libwebpmux3 libyaml-0-2 libzopfli1 opensc opensc-pkcs11 p7zip p7zip-full pcscd python3 python3-args python3-asn1crypto python3-certifi python3-cffi-backend python3-chardet python3-clint python3-crypto python3-cryptography python3-git python3-gitdb python3-idna python3-libcloud python3-lockfile python3-minimal python3-olefile python3-paramiko python3-pil python3-pkg-resources python3-pyasn1 python3-pyasn1-modules python3-requests python3-simplejson python3-six python3-smmap python3-urllib3 python3-yaml python3.6 python3.6-minimal rsync zipalign to install fdroid’s dependencies
  • cd fdroiddata
  • fdroid init && fdroid readmeta which init fdroid
  • fdroid build -l com.nextcloud.client to build the project
  • fdroid publish to generate a signed apk

Your apk file will be located in repo/

Release | New version

  • git clone --recursive to clone the repo
  • cd android
  • ./gradlew assembleGenericRelease to build it

Your apk file will be located in build/outputs/apk/release

I hope this will help someone.

1 Like

Great HOWTO @Swarthon :100:. I was able to run it by copy/pasting:

# ls -l repo/
total 16900
-rw-r--r-- 1 root root 9049175 May  6 12:46 com.nextcloud.client_30010099.apk
-rw-r--r-- 1 root root 8250062 May  6 12:39 com.nextcloud.client_30010099_src.tar.gz

Is there a way to use similar instructions to build a signed APK using a git repository instead of sources downloaded from F-Droid?

The error I was facing disappeared and I don’t know if I was doing something wrong or not. Anyway I modified my post and the new (old) way does what you expect.