-
Notifications
You must be signed in to change notification settings - Fork 499
Bazel Setup Instructions for Mac
The steps to install Bazel on Mac are:
- Set up Rosetta Terminal
- Install Bazel
- Install OpenJDK 8
- Install Python 2 and make sure it is active in your environment
- Set Bazel, Python 2, ANDROID_HOME paths permanently in your terminal
- Prepare the build environment
- Verify that the build is working
- In the Finder app on your Mac, locate the Applications folder from the favorites sidebar.
- Right-click on your Terminal app and create a duplicate Terminal (and rename it accordingly, say Terminal Rosetta, to avoid confusion).
- On the newly created Terminal Rosetta icon, right-click and select "Get info", and under “General”, check the option "Open using Rosetta".
Note: Always use the Rosetta terminal for Bazel setup and running bash setup.sh
or any Bazel build-related commands.
-
Install Bazel following the instructions here. Make sure that you follow the instructions for installing a specific version (Oppia Android requires 4.0.0 and won't build on other versions).
-
That’s it, now Bazel is installed, and you can verify it by running the command:
bazel --version
- Expected Output
bazel 4.0.0
Oppia Android also requires OpenJDK 8.
Follow the instructions here to install OpenJDK 8.
Note that this requires the installation of brew as a pre-requisite, which can be done by following the instructions here. You can then set up your $JAVA_HOME
environment variable using these instructions.
To install Python 2 in MacOS follow the follows the commands given below. Note that this requires installation of brew as a pre-requisite, which can be done by following the instructions here.
brew install pyenv
pyenv install 2.7.18
pyenv global 2.7.18
- To make sure Python 2 is successfully installed and active in your environment, navigate to the oppia-android directory and run the following commands:
export PATH="$(pyenv root)/shims:${PATH}"
python --version
- To set the
Bazel
,Python 2
,ANDROID_HOME
path permanently in your terminal run these commands:sudo nano /etc/paths
- Enter your password, when prompted.
- Go to the bottom of the file, and enter these paths
/Users/{YourMacUserName}/bin $(pyenv root)/shims:${PATH} $HOME/Library/Android/sdk
- Hit control-x to quit.
- Enter “Y” to save the modified buffer.
- That’s it! To test it, in a new terminal window, type:
echo $PATH
Note: You must set the path for Bazel
, Python 2
, ANDROID_HOME
before running bazel build for oppia-android, otherwise you will get an error.
Follow the instructions in oppia-bazel-tools, in order to prepare your environment to support Oppia Android builds.
At this point, your system should be able to build Oppia Android. To verify, try building the APK (from your subsystem terminal -- note that this and all other Bazel commands must be run from the root of the ‘oppia-android’ directory otherwise they will fail):
bazel build //:oppia
(Note that this command may take 10-20 minutes to complete depending on the performance of your machine).
If everything is working, you should see output like the following:
Target //:oppia up-to-date:
bazel-bin/oppia_deploy.jar
bazel-bin/oppia_unsigned/apk
bazel-bin/oppia/apk
INFO: Elapsed time: ...
INFO: 1 process...
INFO: Build completed successfully, ...
Note also that the oppia.apk
under the bazel-bin
directory of your local copy of Oppia Android should be a fully functioning development version of the app that can be installed using adb
Have an idea for how to improve the wiki? Please help make our documentation better by following our instructions for contributing to the wiki.
Core documentation
Developing Oppia
- Contributing to Oppia Android
- Bazel
- Key Workflows
- Testing
- Developing Skills
- Frequent Errors and Solutions
- RTL Guidelines
- Working on UI
- Writing Design Docs
Developer Reference