-
Notifications
You must be signed in to change notification settings - Fork 499
Bazel Setup Instructions for Linux
The steps to install Bazel on Linux are:
- Install Bazel
- Install OpenJDK 8
- Install Python 2 and make sure it is active in your environment
- Set up the ANDROID_HOME environment variable
- Prepare the build environment
- Verify the Android build
Install Bazel from 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).
- Note: if you find any errors related to
cURL
, please set up cURL on your machine. For Linux, you can usesudo apt install curl
.
Oppia Android also requires OpenJDK 8. The Bazel installation instructions above include sections on installing OpenJDK on different platforms.
-
You can run the following to install OpenJDK 8:
sudo apt install openjdk-8-jdk
You can confirm that this is set up using the command java -version
, which should result in three lines being printed out with the first one showing "openjdk version "1.8.0_292".
Tip: Newer linux distributions may not have openjdk-8 anymore. This has been reported for Debian and Ubuntu. If this is your case, openjdk-11 has been tested as a viable alternative.
Ensure that you have Python 2 installed and make sure that it is currently active on your environment. You can do this by using the python --version
command which should show Python 2.X.X. If it doesn’t, click here for a resource on how to install and update Linux to use Python 2.
Tip: Newer linux distributions may not have the python command and instead use python2 and python3. Bazel <5 requires
python
and that cannot be configured. Creating an alias won't solve the problem, you'll need a symlink. To create one, you can run the following:
sudo apt install python-is-python2
Ensure that your ANDROID_HOME
environment variable is set to the location of your Android SDK. To do this, find the path to the installed SDK using Android Studio’s SDK Manager (install SDK 28). Assuming the SDK is installed to default locations, you can use the following commands to set the ANDROID_HOME
variable:
export ANDROID_HOME=$HOME/Android/Sdk/
-
Make sure you have the system environment variable set up for
ANDROID_HOME
as you might have issues getting properly set up if not. If it isn’t set up (on Linux you can check by usingecho $ANDROID_HOME
in a new terminal; it should output the correct path to your Android SDK), on Linux you can move theexport
from above to your~/.bashrc
file to make it permanent (you can apply the change immediately usingsource ~/.bashrc
).
Follow the instructions in oppia-bazel-tools.
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