|
|
## A Note on JDKs
|
|
|
|
|
|
we use the path the JDK path `/usr/lib/jvm/java-11-openjdk-amd64` in this doc. Use what ever is on your system, in some cases the arch is dropped and it's `/usr/lib/jvm/java-11-openjdk`. Also this has been tested with and works with `/usr/lib/jvm/java-17-openjdk-amd64` as well.
|
|
|
we use the path the JDK path `/usr/lib/jvm/java-11-openjdk-amd64` in this doc. Use what ever is on your system, in some cases the arch is dropped and it's `/usr/lib/jvm/java-11-openjdk`. Also this has been tested with and works with `/usr/lib/jvm/java-17-openjdk-amd64` as well. For Mac (if using homebrew) its `/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home/` for arm64 and `/usr/local/Cellar/openjdk@11/11.0.21/libexec/openjdk.jdk/Contents/Home` for x86_64.
|
|
|
|
|
|
## Prepping Tools
|
|
|
## Prepping Tools (skip this section for mac, we get our clang via Android Studio)
|
|
|
|
|
|
Get a copy of [tor-browser-build](https://gitlab.torproject.org/tpo/applications/tor-browser-build/) and checkout the branch that matches your build target
|
|
|
Get a copy of [tor-browser-build](http://eweiibe6tdjsdprb4px6rqrzzcsi22m4koia44kc5pcjr7nec2rlxyad.onion/tpo/applications/tor-browser-build/) and checkout the branch that matches your build target
|
|
|
|
|
|
*(2023.07.13: for 115.x.0-13.0 we still need [pierov:bug_40855_android](https://gitlab.torproject.org/pierov/tor-browser-build/-/tree/bug_40855_android?ref_type=heads) please delete once merged to tbb propper)*
|
|
|
*(2023.07.13: for 115.x.0-13.0 we still need [pierov:bug_40855_android](http://eweiibe6tdjsdprb4px6rqrzzcsi22m4koia44kc5pcjr7nec2rlxyad.onion/pierov/tor-browser-build/-/tree/bug_40855_android?ref_type=heads) please delete once merged to tbb propper)*
|
|
|
|
|
|
We need to build a clang compiler for our target, aarch64, and we need a few armv7 tools for packaging. The compiler we will use is `clang` and we also need a few extras found in `llvm-runtimes`
|
|
|
|
... | ... | @@ -33,12 +33,14 @@ And now both arm7 and aarch64 llvm-runtimes are installed in your clang and it's |
|
|
|
|
|
Geckoview is the core browser engine. It will be compiled for android and prepared for packaging in an android browser.
|
|
|
|
|
|
clone a copy of [tor-browser](https://gitlab.torproject.org/tpo/applications/tor-browser) and check out the relevant branch (eg: tor-browser-115.0b5-13.0-1)
|
|
|
clone a copy of [tor-browser](http://eweiibe6tdjsdprb4px6rqrzzcsi22m4koia44kc5pcjr7nec2rlxyad.onion/tpo/applications/tor-browser) and check out the relevant branch (eg: tor-browser-115.2.1-13.5-1)
|
|
|
|
|
|
create an `android-env.sh` and fill it accordingly to your setup with the following
|
|
|
|
|
|
|
|
|
For Linux:
|
|
|
```
|
|
|
export MOZ_BUILD_DATE=20230601093525 # This should match the data in [firefox-android](https://gitlab.torproject.org/tpo/applications/firefox-android)/android-components/plugins/dependencies/src/main/java/Gecko.kt ~ln 12's def of the variable *version*, the date component
|
|
|
export MOZ_BUILD_DATE=20230710165010 # This should match the data in [firefox-android](http://eweiibe6tdjsdprb4px6rqrzzcsi22m4koia44kc5pcjr7nec2rlxyad.onion/tpo/applications/firefox-android)/android-components/plugins/dependencies/src/main/java/Gecko.kt ~ln 12's def of the variable *version*, the date component
|
|
|
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
|
|
|
export ANDROID_HOME=$HOME/.mozbuild/android-sdk-linux/ # or $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/23.2.8568313/ # for 115esr
|
... | ... | @@ -47,6 +49,17 @@ export LOCAL_DEV_BUILD=1 |
|
|
export PATH=/FULL/PATH/TO/tor-browser-build/out/clang/clang-16.x.y-arm/bin/:$PATH # prepend our newly built and assembled clang to the path so it gets used to build geckoview
|
|
|
```
|
|
|
|
|
|
For Mac: (default is arm64, note the different paths for x86_64). Make sure to download the appropriate NDK's via Android Studio's SDK manager (you can select the specific version by checking the box in the bottom right that says "Show Package Details") ![Screenshot_2023-11-07_at_14.04.00](uploads/bb5eaa40b39284829fb3f21377c61b6f/Screenshot_2023-11-07_at_14.04.00.png)
|
|
|
```
|
|
|
export MOZ_BUILD_DATE=20230710165010 # This should match the data in [firefox-android](http://eweiibe6tdjsdprb4px6rqrzzcsi22m4koia44kc5pcjr7nec2rlxyad.onion/tpo/applications/firefox-android)/android-components/plugins/dependencies/src/main/java/Gecko.kt ~ln 12's def of the variable *version*, the date component
|
|
|
export JAVA_HOME=/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home/ # for arm64. Or JAVA_HOME=/usr/local/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home/ for x86_64.
|
|
|
export ANDROID_HOME=$HOME/Library/Android/sdk # or $HOME/.mozbuild/android-sdk-macosx/
|
|
|
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.2.8568313 # will need to download NDK 23.2.8568313 via android studio
|
|
|
export GRADLE_HOME=/opt/homebrew/Cellar/gradle@7/7.6.3 # for arm64 or /usr/local/Cellar/gradle@7/7.6.3 for x86_64. Make sure the version is up to date
|
|
|
export LOCAL_DEV_BUILD=1
|
|
|
export PATH=$ANDROID_HOME/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/:$PATH # prepend android studios latest ndk to the path so it's clang gets used to build geckoview. NDK 25.2.9519653 uses clang 14.0.7, ideally we'd use clang 16 (to be the same as Linux) but that's not an option yet for android studio. NDK 26.1.10909125 uses clang 17.0.2, which we should evaluate with the esr128 migration
|
|
|
```
|
|
|
|
|
|
Make sure that the variables defined are all valid for your setup, and that PATH is now using our newly built clang.
|
|
|
|
|
|
Then `source android-env.sh` to include
|
... | ... | @@ -73,7 +86,7 @@ rustup target add aarch64-linux-android |
|
|
```
|
|
|
</details>
|
|
|
|
|
|
then build
|
|
|
then build (this may take a while depending on your machine, ranging from 10 minutes to over an hour as of 2023)
|
|
|
|
|
|
```
|
|
|
MOZCONFIG=mozconfig-android-aarch64 ./mach build
|
... | ... | @@ -103,7 +116,7 @@ and after all this we should be able to confirm by running `ls ~/.m2/repository |
|
|
|
|
|
## Building firefox-android
|
|
|
|
|
|
Get a copy of the repo [firefox-android](https://gitlab.torproject.org/tpo/applications/firefox-android) and check out the relevant build branch (eg: firefox-android-115.2.0-13.0-1)
|
|
|
Get a copy of the repo [firefox-android](http://eweiibe6tdjsdprb4px6rqrzzcsi22m4koia44kc5pcjr7nec2rlxyad.onion/tpo/applications/firefox-android) and check out the relevant build branch (eg: firefox-android-115.2.0-13.0-1)
|
|
|
|
|
|
### Android Components
|
|
|
|
... | ... | @@ -152,25 +165,47 @@ dependencySubstitutions.geckoviewTopsrcdir=/FULL/PATH/TO/tor-browser |
|
|
autoPublish.android-components.dir=../android-components
|
|
|
```
|
|
|
|
|
|
You will also need to fetch the artifacts from `tor-android-service` and `tor-onion-proxy-library`,
|
|
|
You will also need the artifacts from `tor-android-service` and `tor-onion-proxy-library`.
|
|
|
If ever ran an Android build with tor-browser-build, you can use the `fenix/tools/tba-fetch-deps.sh` script.
|
|
|
It assumes `tor-browser-build.git` has been checked out at the same level of `firefox-android.git`, but you can also specify another directory with the `TOR_BROWSER_BUILD` environment variable.
|
|
|
|
|
|
Open `fenix` in android studio and build (`Build > Make Project`).
|
|
|
|
|
|
#### Generating non dev builds (nightly, beta(alpha), release)
|
|
|
|
|
|
As an alternative, you can also build from the command line:
|
|
|
|
|
|
```
|
|
|
./gradlew --no-daemon -Dorg.gradle.jvmargs=-Xmx20g -PversionName="$variant" assemble$variant
|
|
|
gradle --no-daemon -Dorg.gradle.jvmargs=-Xmx20g assemble$variant
|
|
|
```
|
|
|
|
|
|
where `$variant` must be one of `Release`, `Beta` or `Nightly` (notice the capital letter to make the result camelCase).
|
|
|
|
|
|
#### Running
|
|
|
## Running
|
|
|
|
|
|
From Android Studio with `fenix` loaded simply select from the menu `Run > Run 'app'` with an appropriate android device with USB debugging enabled plugged in.
|
|
|
|
|
|
From Android Studio with `fenix` loaded simply select from the menu `Run > Run 'app'` with an appropriate android device with USB debugging enabled plugged in and you will build and run a dev build.
|
|
|
Otherwise, you can sign the apks with the same QA key we use for the builds from tor-browser-build with `fenix/tools/tba-sign-devbuilds.sh`.
|
|
|
This binary assumes that you have `tor-browser-build.git` at the same level of `firefox-android.git`, but you can override this with the `TOR_BROWSER_BUILD` environment variable.
|
|
|
|
|
|
### For MacOS:
|
|
|
|
|
|
For quickly building, aligning, signing, and installing (to an emulator or device plugged in) the following is useful. Replace the values for variant and Variant with the variant of your choice. Also point the apksigner to your keystore, see https://developer.android.com/studio/publish/app-signing#generate-key for generating a key.
|
|
|
```
|
|
|
export Variant=Beta && export variant=beta
|
|
|
./gradlew clean --no-daemon -Dorg.gradle.jvmargs=-Xmx20g assemble$Variant
|
|
|
cd app/build/outputs/apk/fenix/$variant
|
|
|
zipalign -v -p 4 app-fenix-arm64-v8a-$variant-unsigned.apk app-fenix-arm64-v8a-$variant-unsigned-aligned.apk
|
|
|
apksigner sign -ks ../../../../../../my-release-key.jks --out app-fenix-arm64-v8a-$variant.apk app-fenix-arm64-v8a-$variant-unsigned-aligned.apk
|
|
|
adb install app-fenix-arm64-v8a-$variant.apk
|
|
|
cd ../../../../../..
|
|
|
```
|
|
|
|
|
|
An example section for `~/.zshrc` to get it to run
|
|
|
```
|
|
|
export JAVA_HOME=/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home/ # or your equilivent
|
|
|
export ANDROID_HOME=$HOME/Library/Android/sdk
|
|
|
export PATH=$PATH:$ANDROID_HOME/platform-tools/
|
|
|
export PATH=$PATH:$ANDROID_HOME/build-tools/34.0.0/
|
|
|
```
|
|
|
|
|
|
If you have built a specific *variant* for firefox-android as shown above, you can sign the apks with the same QA key we use for the builds from tor-browser-build with `fenix/tools/tba-sign-devbuilds.sh`.
|
|
|
This binary assumes that you have `tor-browser-build.git` at the same level of `firefox-android.git`, but you can override this with the `TOR_BROWSER_BUILD` environment variable. Then you can use `adb` to install the package with something like `adb install ./app/build/outputs/apk/fenix/beta/app-fenix-arm64-v8a-beta-signed.apk` |
|
|
The last line assumes "Android SDK Build-Tools 34" is installed
|
|
|
![Screenshot_2023-11-09_at_15.18.22](uploads/759156213ed8d7ef392845d4aa88fb7d/Screenshot_2023-11-09_at_15.18.22.png) |
|
|
\ No newline at end of file |