How to publish your apps on F-Droid?
Tags: opensource, android
Published: 2020-09-26 11:03:23

>F-Droid is a community-maintained repository of free and open-source software for Android, similar to Google Play store. But unlike Google Play store, F-Droid only contains open-source apps that respect your freedom.

Publishing apps on F-Droid may seem a little confusing for newbies.
Recently, I published my first free and open-source app on F-Droid(Check it out [here](https://f-droid.org/packages/tech.projectmatris.antimalwareapp)).

In this post, I will walk you through the steps that I followed to publish my app on F-Droid.

>NOTE: Your app can be included in F-Droid only if it is completely open-source - including all libraries and dependencies used. Learn more about their inclusion policy [here](https://www.f-droid.org/en/docs/Inclusion_Policy/).

Note that I am using Linux environment and I didn't test these on a Windows machine.

##### Step 1:

First you need a [GitLab](https://gitlab.com) account beacuse the F-Droid repository is hosted on GitLab. After registering on GitLab, you need to fork [fdroiddata](https://gitlab.com/fdroid/fdroiddata) repository.

##### Step 2:

Install [fdroidserver](https://gitlab.com/fdroid/fdroidserver). This can be done using apt:
```
sudo apt install fdroidserver
```
But I faced some issues while using fdroidserver that is installed using apt.
So I recommend using it directly from master:
```
git clone https://gitlab.com/fdroid/fdroidserver.git
export PATH="$PATH:$PWD/fdroidserver"
```
##### Step 3:

Clone fdroiddata(or your fork) and enter it:
```
git clone https://gitlab.com/fdroid/fdroiddata
cd fdroiddata
```
##### Step 4:

Run the following commands to make sure `fdroid` works and reads the metadata files properly:
```
fdroid init
fdroid readmeta
```
##### Step 5:

Use `fdroid import` command to add your project:
```
fdroid import --url https://github.com/YOUR-USERNAME/REPO --subdir app
```
Replace with the link to your project repository after --url tag.
##### Step 6:

The above step will create a file in the metadata directory, something like *metadata/app.id.yml*
Open and edit this file using a text editor:
```
nano metadata/YOUR-APP-ID.yml
```
You have to fill in your app details like Categories, License, WebSite etc. You can read about it [here](https://f-droid.org/en/docs/Build_Metadata_Reference).
##### Step 7:

Run the following command to make sure that the metadata file is complete and error free:
```
fdroid readmeta
```
##### Step 8:

Run the following command to clean up your file:
```
fdroid rewritemeta YOUR-APP-ID
```
##### Step 9:

Run the following command and make sure that it doesn't report any warnings:
```
fdroid lint YOUR-APP-ID
```
If there are any warnings, fix them.
##### Step 10:

Let's actually build the app using the following command:
```
fdroid build -v -l YOUR-APP-ID
```
If you don't have Android Sdk set up on your computer or if you don't set it up correctly, you may encounter an error in this step. Don't worry, install the sdk and set the path correctly. In my case, the path was not set correctly. So I used following commands to correct the error:
```
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
```
Note: If you still encounter any errors/warnings due to something that is not configured in your machine, I recommend moving to next step and check if the pipeline is passing after it is pushed to GitLab.
##### Step 11:

Now you can commit and push to our GitLab repository(to your fork). This can be done using the following commands:
```
git add .
git commit -m "Added <Your App Name Here>"
git remote set-url origin https://gitlab.com/YOUR-USERNAME/fdroiddata.git
git push -u origin master
```
##### Step 12:

Check the CI/CD pipelines. Now you can make a merge request which will be reviewed by F-Droid maintainers and if everything is fine, they will merge it to their main branch.

**Additional Info:** If you want to include, graphic assets like icon, screenshots etc. you can include it by adding a Fastlane or Triple-T folder structure in your app's repo. You can read about it [here](https://f-droid.org/en/docs/All_About_Descriptions_Graphics_and_Screenshots/#fastlane-structure).
For example, I included a fastlane folder structure in my app's repo by creating these folders: fastlane/metadata/android/
You can add graphic assets in the images folder. If you want to include screenshots, you need to create a folder called phoneScreenshots inside images and add your screenshots there. You can also add summary and descriptions also in fastlane/metadata/android/ folder and remove it from the metadata YML file so that you don't need to open a new merge request each time you make any changes in description, summary etc. If you need reference, check out my project [here](https://github.com/projectmatris/antimalwareapp). Finally, don't forget to update the commit id in the metadata YML file.

Phew, that's it!

It may take one or two days to appear in the F-Droid app store after your app metadata is merged. 

You can advertise the download of your app in F-Droid using the [official grafic](https://fdroid.gitlab.io/artwork/badge/get-it-on.png). <img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" width="200">
```
<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" height="75">
```

So what do you think about F-Droid? Did you publish your apps on F-Droid? Let me know in the discussion below.

#### References:
1. https://gitlab.com/fdroid/fdroiddata/-/blob/master/CONTRIBUTING.md
2. https://www.f-droid.org/en/docs/Inclusion_Policy/
3. https://f-droid.org/docs/Build_Metadata_Reference/
4. https://f-droid.org/en/docs/All_About_Descriptions_Graphics_and_Screenshots/
5. https://blog.fossasia.org/publish-an-open-source-app-on-fdroid/