Publishing Your Flutter App on F-Droid

Nikhil Jha | | 2 minute read


So you made a Flutter app, and it’s open source. Normally the first thing you’d do is upload it to F-Droid - but at first glance, it looks like F-Droid doesn’t support Flutter! Luckily the workaround is so easy it doesn’t even feel like a workaround.

It’s as easy as 1, 2, 3! (I’ve always wanted to say that, and yes I realize that I skipped a few numbers between 2 and 6.)

Steps

  1. If you have signing setup already, move the config for signing (inside your application build.gradle) into the actual signing config like so:

This step can be safely ignored if you still are using the null signing config.

    signingConfigs {
        release {
            def keystorePropertiesFile = rootProject.file("key.properties")
            def keystoreProperties = new Properties()

            if (!keystorePropertiesFile.exists()) return;

            keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }

  1. Add a new fdroid product flavor like so:
    flavorDimensions "deploy"

    productFlavors {
        fdroid {
            dimension "deploy"
            signingConfig null
        }
    }

    android.applicationVariants.all { variant ->
        if (variant.flavorName == "fdroid") {
            variant.outputs.all { output ->
                output.outputFileName = "app-fdroid-release.apk"
            }
        }
    }
  1. Use this in your build config in the fdroid data. Need a starter config? See here. All you need to do is clone that repository, copy that config, edit the values, and submit a merge request AFTER TESTING it. For more information on that process, look here.
Builds:
  - versionName: changeme
    versionCode: changeme
    commit: your_git_tag
    output: build/app/outputs/apk/fdroid/release/app-fdroid-release.apk
    srclibs:
      # I usually use the dev version of flutter, but beta and removing the @ altogether works too.
      - flutter@dev
    prebuild: rm -fr ios # iOS folder has binaries sometimes
    build: |-
        export PATH=$$flutter$$/bin:$PATH && flutter build apk --flavor fdroid

Full Examples

build.gradle: Lobsters App and Trireme.

fdroid config: Trireme