Tor Project's fork of Mozilla's application-services.
  • Rust 88.4%
  • Kotlin 5.8%
  • Python 3.4%
  • Shell 1.7%
  • Swift 0.5%
  • Other 0.1%
Find a file
Dan Ballard 950c9d7001 fixup! Create a README.md file
TB 44849: Add note about RUST_ANDROID_GRADLE_PYTHON_COMMAND and python3
2026-04-16 14:33:00 -07:00
.cargo Grafana dashboard generator tool (#7123) 2025-12-30 14:43:08 +00:00
.circleci Fix uniffi revision (#7217) 2026-02-26 02:11:08 +00:00
.github Update changelog link in PR template (#7129) 2026-02-24 23:40:31 +00:00
.vscode chore(vscode): crates extension was renamed to dependi (#7170) 2026-01-17 00:29:47 +00:00
automation Modify autopublish command to accept uniffi-bindgen path 2026-03-25 10:02:39 -07:00
build-scripts fixup! No-op most of the megazord components 2026-04-15 17:29:50 +02:00
components Have viaduct always return a backend error 2026-03-25 09:59:45 -07:00
docs Update instructions for vendoring into m-c (#7256) 2026-03-15 23:45:24 +00:00
examples Revert "Removing legacy remote-settings client (#7186)" (#7255) 2026-03-03 00:33:40 +00:00
gradle Update various Gradle dependencies (#7272) 2026-03-20 18:06:06 +00:00
libs fixup! No-op most of the megazord components 2026-04-15 17:29:50 +02:00
megazords No-op most of the megazord components 2026-03-25 09:59:45 -07:00
taskcluster Update NSS to 3.121 (#7232) 2026-02-20 20:32:25 +00:00
testing Add viaduct-hyper to the iOS megazord (#7169) 2026-01-20 16:23:09 +00:00
tools Error dashboards: filter logs when group by build date is set (#7280) 2026-03-20 12:48:47 +00:00
.buildconfig-android.yml remove nimbus-gradle-plugin (#7184) 2026-01-29 00:48:33 +00:00
.cron.yml ci: don't run the nightly cron job on the staging-application-services repo (#7168) 2026-01-26 09:17:43 +00:00
.detekt.yml Align Detekt config with mozilla-central 2025-08-06 20:17:09 +00:00
.editorconfig Update ktlint to version 1.8.0 (#7143) 2026-01-06 18:20:20 +00:00
.gitignore Update docs for local ios builds. (#7132) 2026-01-07 01:08:05 +00:00
.gitlab-ci.yml TB 44860: Add CI for generating test builds 2026-04-16 12:32:57 -03:00
.gitmodules Remove unused Glean submodule (#7103) 2025-12-08 09:53:46 +00:00
.mailmap Add .mailmap 2024-07-09 19:21:41 +00:00
.mergify.yml Remove swift wrappers from a-s [ci full] (#6925) 2025-09-09 18:53:21 +00:00
.taskcluster.yml ci: migrate linux tasks to d2g worker pools (bug 2007500) (#7138) 2025-12-24 09:55:16 +00:00
build.gradle Allow users to define a custom gradle depencies location 2026-03-25 09:59:45 -07:00
Cargo.lock Bug 2020855 - add timestamps to breadcrumb data (#7279) 2026-03-20 13:41:20 +00:00
Cargo.toml Fix uniffi revision (#7217) 2026-02-26 02:11:08 +00:00
CHANGELOG.md Cut release v150.0 (#7285) 2026-03-23 15:18:32 -04:00
clippy.toml Document our use of clippy and add a (empty) clippy.toml 2019-03-20 09:02:54 -07:00
CODE_OF_CONDUCT.md Bring CPG in line with CPGBot's demands, fixes #887 2019-03-31 15:38:31 -07:00
COPYRIGHT Remove the ffi-support crate sources from this repo. 2021-06-01 15:56:49 +10:00
DEPENDENCIES.md upgrade uniffi to 0.31 (#7140) 2026-01-27 04:52:32 +00:00
detekt-baseline.xml Add detekt baseline 2025-08-06 20:17:09 +00:00
gradle.properties Add missing license headers 2024-12-04 03:29:05 +00:00
gradlew Update Gradle to version 8.14.3 2025-07-07 22:09:08 +00:00
gradlew.bat Update Gradle to version 8.14.3 2025-07-07 22:09:08 +00:00
install-nimbus-cli.sh Build linux nimbus binaries with Ubuntu 20.04 2023-09-21 16:01:57 +00:00
LICENSE rc_crypto initial commit (#1349) 2019-07-09 14:00:48 -04:00
license.template Align Detekt config with mozilla-central 2025-08-06 20:17:09 +00:00
moz.build Add build tooling so we can work in mozilla-central. 2025-07-08 20:29:19 +00:00
proguard-rules-consumer-jna.pro Include classes that extend from JNA Structure in proguard consumer rules (#6979) 2025-09-27 14:13:10 +00:00
publish.gradle Add an explicit import for XmlSlurper 2025-08-08 16:51:31 +00:00
README.md fixup! Create a README.md file 2026-04-16 14:33:00 -07:00
rust-toolchain.toml Updating Rust to 1.91.0 (#7099) 2025-11-21 17:12:49 +00:00
settings.gradle Allow users to define a custom gradle depencies location 2026-03-25 09:59:45 -07:00
version.txt Add TORBROWSER version suffix 2026-03-25 10:02:30 -07:00

Application Services

This repository contains the fork of application-services used by Tor Browser for Android.

The main differences from this project to the original are a few patches that allow it to be built in tor-browser-build and patches that disable most of the features from application-services either run time or build time.

Structure

tl;dr; It's a bunch of Rust components grouped together in the "megazord" crate and exposed to Android code through auto-generated Kotlin bindings.

The bulk of the logic implemented in application-services is written in Rust and separated into components. All components are in the /components directory.

This components are gathered in the "megazord" Rust crate, to be conveniently added into application as a single library. There are multiple "megazord" crates in /megazord, but the only one we care about is the one under megazords/full.

The features exposed by the megazord have to be accessed from Android applications -- and iOS, but for us that is not supported and thus irrelevant. For that, Kotlin bindings are generated using Uniffi when building each component.

Building

The process to build this project is similar to the original build steps of application-services with a few tweaks.

Note

own documentation at the Application Services Book.

Also, you might want to check the original README in the upstream repository, or have a look at upstream's build instructions.

Setup

uniffi-rs

Before building application-services it's necessary to procure a build of our fork of uniffi-rs. There are two possibilities for that, either you build it yourself:

git clone https://gitlab.torproject.org/tpo/applications/uniffi-rs.git
cd uniffi-rs
cargo build [--release]

Or you can grab a build from https://tb-build-06.torproject.org/~tb-builder/tor-browser-build/out/uniffi-rs/

Toolchain setup

This project requires specific versions of the Android toolchain to be available. The exact versions of each component can be checked in settings.gradle (search for ndkVersion).

Android SDK

After all the required components are downloaded, it is recommended to set the location of the Android SDK in local.properties, like so:

sdk.dir=/path/to/android-sdk

This is recommended because it will always prefer this path, even if building from a different folder with different toolchain defaults -- which is the case when substituting a-s for a local build of tor-browser.

Note

: Usually application-services uses the same SDK and NDK versions as required by tor-browser. When using ./mach bootstrap to download toolchains in tor-browser, you can set sdk.dir to $HOME/.mozbuild/android-sdk-linux:

sdk.dir=/home/<you>/.mozbuild/android-sdk-linux
Android NDK

The build expects the ndk to be located inside /path/to/android-sdk/ndk/XX.X.XXXXXX (where XX.X.XXXXXX is the version found in settings.gradle for the NDK). You can easily find it with this command:

grep ndkVersion settings.gradle

If you are using Firefox's SDK and NDK, you will need to create a symlink to it, as the NDK is not inside the SDK folder, but next to it:

mkdir -p ~/.mozbuild/android-sdk-linux/ndk
cd ~/.mozbuild/android-sdk-linux/ndk
ln -s ../../android-ndk-rXYZ XX.X.XXXXXX
Rust

Make sure all the Android Rust targets are available, before building:

rustup target add aarch64-linux-android
rustup target add x86_64-linux-android
rustup target add armv7-linux-androideabi
rustup target add i686-linux-android
gyp

For some reason, NSS uses the gyp project generator rather than some more common tool such as CMake.

On Linux, you should find it in your distribution:

# Debian, Ubuntu, and derivatives
apt install gyp
# Arch Linux and derivatives
pacman -Sy gyp

On macOS, you can install gyp-next from pip:

python3 -m pip install gyp-next

gyp in turn uses ninja, but it is very likely you already have it in your system.

Build

The first part of the build happens in the libs directory:

cd libs
./build-all.sh desktop

This builds both some dependencies (such as NSS) and the unpatched megazord.

We need to do it, as the no-op version grabs the interfaces to create from the unpatched one.

After that, we need to build NSS for Android:

export ANDROID_HOME=$HOME/.mozbuild/android-sdk-linux/
export ANDROID_NDK_HOME=$HOME/.mozbuild/android-ndk-r29/
export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME
./build-all.sh android

And then the Android bindings:

cd .. # Assuming you were in the libs directory, otherwise go to the repo root.
./gradlew -PuniffiBindgenNoop="/path/to/the/uniffi-bindgen/binary" assemble(Release|Debug)

The uniffi binary is usually .../uniffi-rs/target/release/bindgen.

Note

: the shell won't escape ~, so be sure not to use it to specify this path. Instead you can use $HOME.

Note

: This command can fail when calling linker-wrapper.sh which is hardcoded to call python. If you are in an env with only python3 it will fail. You can append env RUST_ANDROID_GRADLE_PYTHON_COMMAND=python3 to the front of this command to tell it to use python3

If you want to package it:

./gradlew -PuniffiBindgenNoop="/path/to/the/uniffi-bindgen/binary" publish

That will create a new local maven repository in build/maven. You can merge it to your existing local repo with this command:

cp -R build/maven/org ~/.m2/repository/

Troubleshooting

Cleanup

Just running clean in gradle is not enough, as it will not delete the binaries built with Cargo.

There isn't an official cleanup script for the libs directory. So, in doubt, you might run rm -rf android desktop.

It might be useful also to remove the various target directories (one is in the root of the repository, the other one is megazords/full/target).

After the cleanup, be sure to re-run also the steps in the libs directory!

Failed to open file .../libmegazord.so

Re-run ./build-all.sh desktop in the libs directory.