Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Tor Browser Tor Browser
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 834
    • Issues 834
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 5
    • Merge requests 5
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • The Tor Project
  • Applications
  • Tor BrowserTor Browser
  • Wiki
  • Hacking

Hacking · Changes

Page history
Update Android instructions (WIP) authored Oct 13, 2022 by Pier Angelo Vendrame's avatar Pier Angelo Vendrame
Hide whitespace changes
Inline Side-by-side
Hacking.md
View page @ df8bf6c6
......@@ -198,71 +198,19 @@ $ ./mach bootstrap
At the first menu, you most likely want option `4. GeckoView/Firefox for Android`. Accept the license agreement. You can decline optimizations, if you don't want them.
As an alternative, you can extract the required tooling from `tor-browser-build`, and add it to the correct `PATH`.
```
Your system should be ready to build GeckoView/Firefox for Android!
Paste the lines between the chevrons (>>> and <<<) into
/home/user/tor-browser/.mozconfig:
>>>
# Build GeckoView/Firefox for Android:
ac_add_options --enable-application=mobile/android
# Targeting the following architecture.
# For regular phones, no --target is needed.
# For x86 emulators (and x86 devices, which are uncommon):
# ac_add_options --target=i686
# For newer phones or Apple silicon
# ac_add_options --target=aarch64
# For x86_64 emulators (and x86_64 devices, which are even less common):
# ac_add_options --target=x86_64
<<<
```
There is a `.mozconfig-android` in the tree, but it needs some updating. Instead, we'll create a new `mozconfig` for the Android build. We'll assume a `x86_64` target. Put this in a new file named `.mozconfig-android2`:
In both cases, running an Android build locally requires a few environment variables to be defined:
```bash
# Firefox needs to know the directory of the JDK, you might use a different one in your system
export MOZ_BUILD_DATE=20220705093820 # This is for 102, but set the correct one, you can find it in android-components/buildSrc/src/main/java/Gecko.kt
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export ANDROID_HOME=$HOME/Android/Sdk/ # Or .../android-toolchain/android-sdk-linux if you extract android-toolchain from tor-browser-build
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/android-ndk-r21d # At least this works with android-toolchain from tor-browser-build, not sure about the official Android SDK
export GRADLE_HOME=.../gradle-7.3 # Or the version that we currently use
export LOCAL_DEV_BUILD=1 # Enable some tweaks on our mozconfigs
```
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-x86_64-linux-android
mk_add_options MOZ_APP_DISPLAYNAME="Tor Browser"
# Build GeckoView/Firefox for Android:
ac_add_options --enable-application=mobile/android
ac_add_options --target=x86_64
ac_add_options --enable-optimize
ac_add_options --enable-rust-simd
ac_add_options --enable-official-branding
# https://bugzilla.mozilla.org/show_bug.cgi?id=1758568
ac_add_options --enable-minify=properties
# We do not use Tor Launcher on Android:
ac_add_options --disable-tor-launcher
ac_add_options --disable-tor-browser-update
ac_add_options --disable-verify-mar
# We only use beta GeckoView for now; use default for local builds
ac_add_options --enable-update-channel=default
ac_add_options --enable-strip
ac_add_options --disable-tests
ac_add_options --disable-debug
ac_add_options --disable-rust-debug
ac_add_options --disable-crashreporter
ac_add_options --disable-webrtc
ac_add_options --disable-parental-controls
ac_add_options --enable-proxy-bypass-protection
# Disable telemetry
ac_add_options MOZ_TELEMETRY_REPORTING=
```
This content is based on the config we use in [Tor Browser Build](https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/blob/master/projects/geckoview/mozconfig-android-x86_64).
Note: `--enable-update-channel=default`. This is necessary.
#### Android-Components
......@@ -382,6 +330,15 @@ $ find obj-x86_64-linux-android/gradle/maven/org/mozilla/geckoview/geckoview-bet
obj-x86_64-linux-android/gradle/maven/org/mozilla/geckoview/geckoview-beta-omni/99.0.20220506224557-SNAPSHOT/geckoview-beta-omni-99.0.20220506224557-20220506.233506-1.aar
```
After you finish building one or more single-arch Geckoview, you should create a fat AAR (even if you only have one architecture).
We have a make target in `tools/torbrowser`:
```bash
make fat-aar ARCHS="armv7" # Specify the architectures you prefer separated by a space
```
If you are compiling a `release` version (not `beta` or `nightly`), then modify `substitute-local-geckoview.gradle` like the below patch, adding `geckoview-omni` as a valid package name:
```diff
......
Clone repository
  • Codebases
  • Debugging
    • Android
    • Windows
  • Firefox Version Audit
  • Hacking
  • Hardening
  • Next Change Logs
  • Nightly_Builds_Download
  • Nightly_Builds_Setup
  • Platform_Installation
  • Quality Assurance on Tor Browser Releases
  • Quality Assurance
  • Release Schedule
  • Reproducible Builds
    • Debugging Android
  • Sandbox
View All Pages