fenix.rst (4767B)
1 .. _fenix-contributor-guide: 2 3 Building Firefox for Android 4 ============================ 5 6 As a first step, you need to set up your development environment using the instruction :ref:`here <firefox_for_android>`. 7 8 Before building, set the paths to your Java installation and Android SDK 9 10 **macOS** 11 12 .. code-block:: shell 13 14 export JAVA_HOME=$HOME/.mozbuild/jdk/jdk-<latest-version>/Contents/Home 15 export ANDROID_HOME=$HOME/.mozbuild/android-sdk-<os_name> 16 17 **non-macOS** 18 19 .. code-block:: shell 20 21 export JAVA_HOME=$HOME/.mozbuild/jdk/jdk-<latest-version> 22 export ANDROID_HOME=$HOME/.mozbuild/android-sdk-<os_name> 23 24 25 Build Fenix using command line 26 ------------------------------ 27 28 From the root mozilla-central directory, build Fenix: 29 30 .. code-block:: shell 31 32 ./mach gradle fenix:assembleDebug 33 34 You can then find the generated debug apks in objdir under 35 ``gradle/build/mobile/android/fenix/app/outputs/apk/debug`` 36 37 38 Run Fenix or other Android projects using command line 39 --------------------------------------------------------- 40 .. _run_fenix_from_commandline: 41 42 You can run the following command to launch an emulator and install and run Fenix: 43 44 .. code-block:: shell 45 46 ./mach run --app=fenix 47 48 Run Fenix tests 49 ------------------- 50 51 You can run tests via all the normal routes from within Android Studio: 52 53 - For individual test files, click the little green play button at the top 54 - For a module/component: 55 56 - Right click in project explorer → run all tests 57 - Select from gradle tasks window 58 59 If you see the error "Test events were not received", check your top level folder - this happens if you try and run tests in Android Components from ``mozilla-unified/mobile/android/fenix/``. 60 To build tests for Android Components you need to be using the ``build.gradle`` in ``mozilla-unified/mobile/android/android-components/``. 61 62 Alternatively, you can run tests from command line using: 63 64 - ``./mach test <file-name>`` to run all tests in the file 65 - ``./mach test <directory-name>`` to run all tests in the directory 66 - ``./mach test {fenix,focus,ac,android-components,geckoview}`` to run all tests in the specific project 67 68 If after running tests on your Android device, you can no longer long press, this is because the connected Android tests mess around with your phone’s accessibility settings. 69 They set the long press delay to 3 seconds, which is an uncomfortably long time. 70 To fix this, go to Settings → Accessibility → Touch and hold delay, and reset this to default or short (depends on manufacturer). 71 72 Lint 73 ------------------- 74 75 You can run the following commands to verify that your code is formatted correctly: 76 77 - ``./mach lint -l android-fenix`` to lint changes made in fenix directory 78 - ``./mach lint -l android-focus`` to lint changes made in focus directory 79 - ``./mach lint -l android-ac`` to lint changes made in android-components directory 80 81 You can find more linters by running ``./mach lint --list`` 82 You can pass an extra argument ``--fix`` to autofix certain types of reported issues. 83 84 Preset Try 85 ------------------- 86 87 It is advisable to run your tests before submitting your patch. You can do this using Mozilla’s ``try`` server. 88 The following commands will ensure that all the required tests are run based on the changes made: 89 90 - ``./mach try --preset fenix`` - will run Fenix test suites 91 - ``./mach try --preset firefox-android`` - will run AC and Fenix test suites 92 - ``./mach try --preset android-geckoview`` - will run GeckoView test suites 93 94 Failures on ``try`` will show up with the test name highlighted in orange. Select the test to find out more. 95 Intermittent failures occasionally occur due to issues with the test harness. Retriggering the test is a good way to confirm it is an intermittent failure and not due to the patch. 96 Usually there will also be a bug number with a portion of the stack trace as well for documented intermittent failures. 97 98 Speed Up the CI 99 ------------------- 100 101 Currently, the CI builds GeckoView even if your commit doesn't impact it. 102 103 If you know your changes don't impact GeckoView, you can try using the following option: ``--use-existing-tasks`` or ``-E``. For example: 104 105 ``./mach try --preset firefox-android -E`` 106 107 This will try to reuse a GeckoView build from a previous CI job, and thus reduce the CI time. 108 109 Other Links: 110 ------------------- 111 112 .. toctree:: 113 :maxdepth: 1 114 115 Understanding Artifact Builds <https://firefox-source-docs.mozilla.org/contributing/build/artifact_builds.html> 116 Pushing to Try <https://firefox-source-docs.mozilla.org/tools/try/index.html> 117 Submitting a Patch <https://firefox-source-docs.mozilla.org/contributing/how_to_submit_a_patch.html> 118 Landing a Patch <https://moz-conduit.readthedocs.io/en/latest/lando-user.html>