Fdroid is a place for open source enthusiasts and developers to host their Free and Open Source Software (FOSS) for free and get more people onboard into their community. In order to host an app in their repository, one has to go through a several steps of builds and tests. This is to ensure that the software provided by them are as quality and safe as they can ever be. They are not allowing proprietary libraries or tools to integrate into any app or they will be published outside the Fdroid main repository (fdroid-data) so that the users will know what they are downloading.
In a normal Linux computer where we are developing Android apps and have setup Android Studio will not be able to run the build command using:
$ fdroid build -v -l org.fossasia.pslab
The reason behind this is that we have not installed gradle and build tools required by the “fdroid build” because they are not useful in our day today activities for standalone activities. First thing we need to do is, install gradle separately. This will include adding gradle to $PATH as well.
Download the latest gradle version zip file or the version your project is using with the following command. In PSLab Android app, we are using 4.5.1 version and the snippet below include that version.
$ wget https://services.gradle.org/distributions/gradle-4.5.1-bin.zip
Next step is to install this in a local folder. We can select any path we want, but /opt/ folder is generally used in such scenarios.
sudo mkdir /opt/gradle sudo unzip -d /opt/gradle gradle-4.5.1-bin.zip
Then we can add gradle to our $PATH variable using the following command:
$ export PATH=$PATH:/opt/gradle/gradle-4.5.1/bin
Now we are all set with gradle settings. Next step is to verify that the fdroid server is properly configured and up to date. When you run the build command after setting up the gradle in PC, it will throw an error similar to “failed to find any output apks”. This causes if the installed fdroid server version is old.
Fdroid server is running on python 3 and it will require some additional libraries pre-installed to properly function.
$ sudo apt-get install vagrant virtualbox git python3-certifi python3-libvirt python3-requestbuilder python3-yaml python3-clint python3-vagrant python3-paramiko python3-pyasn1 python3-pyasn1-modules
Once these libraries are installed, remove the previous instance of fdroidserver by using the following command:
$ sudo apt-get remove fdroidserver
Then we can reinstall the latest version of fdroid server from git using the following command:
$ git clone https://gitlab.com/fdroid/fdroidserver.git export PATH="$PATH:$PWD/fdroidserver"
Now we are all set to do a brand new lint build on our PC to make our app ready to be published in Fdroid repository!
Reference:
- Install gradle : https://www.vultr.com/docs/how-to-install-gradle-on-ubuntu-16-10
- Gradle versions : https://gradle.org/releases
- Setting up Fdroid-server : https://f-droid.org/en/docs/Build_Server_Setup/
Installing fdroidserver : https://gitlab.com/fdroid/fdroiddata/blob/master/README.md#quickstart