Skip to content

Commit

Permalink
Merge branch 'develop' into new-onboarding-platform-param
Browse files Browse the repository at this point in the history
  • Loading branch information
BenHenning authored Feb 6, 2024
2 parents 0696b6a + d04fee4 commit 39a5b9b
Showing 1 changed file with 84 additions and 7 deletions.
91 changes: 84 additions & 7 deletions wiki/Bazel-Setup-Instructions-for-Windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,36 @@ After that, follow each of the subsections below as needed to install prerequisi

**Java**

JDK 8 is required for the Android build tools, and we suggest installing OpenJDK:
Bazel Setup requires both JDK 8 and JDK>=17 to complete the setup.

- JDK >= 17 is required for [Android Package Manager](#3-installing-the-android-sdk).
- JDK 8 is required for the [Android build tools](#6-verifying-the-build), and we suggest installing OpenJDK.

(Note: Our recommendation is to install both JDK 8 and JDK 17 and always make sure to run sdkmanager commands with JDK 17 and build commands with JDK 8. `sudo update-alternatives --config java` is used to set the default Java version).

**Install JDK 8**

```sh
sudo apt install openjdk-8-jdk-headless
```

#### For Fedora 25+
**Install JDK 17**

```sh
sudo apt install openjdk-17-jdk
```

#### For Fedora 25+

- Install JDK 8 by running this command on the terminal:
```
sudo dnf install java-1.8.0-openjdk
```
- Set the default Java version to jdk-8 by running the following command `sudo update-alternatives --config java` and selecting the number with jdk-8.

- Install JDK 17 by running this command on the terminal:
```
sudo dnf install java-17-openjdk
```

#### Follow [these instructions](https://www.java.com/en/download/help/path.html) to correctly set up $JAVA_HOME.

Expand All @@ -76,6 +94,28 @@ Unfortunately, some of the Bazel build actions in the Android pipeline require P
sudo apt install python
```

(This might throw an error - **E**: Package 'python' has no installation candidate)

Alternatively, installl Python 2 using:

```sh
sudo apt install python2
```

To make python2 command accessible as python create a symbolic link from python2 to python:

```sh
sudo ln -s /usr/bin/python2 /usr/bin/python
```

**GCC**

Install gcc using the following command:

```sh
sudo apt install gcc
```

### 3. Installing the Android SDK

We need to be able to run Linux-compatible Android utilities which requires installing a Linux version of the Android SDK. Since we can't install Android Studio in the subsystem, we need to do this via CLI commands. The steps below are extracted from [this article](https://proandroiddev.com/how-to-setup-android-sdk-without-android-studio-6d60d0f2812a).
Expand All @@ -86,10 +126,10 @@ First, prepare the environment for the SDK by creating the default directory to
mkdir -p $HOME/Android/Sdk
```

Second, navigate to https://developer.android.com/studio#command-tools in a web browser (in Windows) and select to download the latest **Linux** command tools (even though you're using Windows, the Linux commandline tools are needed--the Windows version will not work with these instructions). Once downloaded, copy the zip file to the new SDK location (note that the ``/c/mnt/...`` path is based on ``C:\Users\<Name>\Downloads`` being the default download location--this may not be the case on your system) with your Windows username filled in for ``<Name>``:
Second, navigate to https://developer.android.com/studio#command-tools in a web browser (in Windows) and select to download the latest **Linux** command tools (even though you're using Windows, the Linux commandline tools are needed--the Windows version will not work with these instructions). Once downloaded, copy the zip file to the new SDK location (note that the ``/mnt/c/...`` path is based on ``C:\Users\<Name>\Downloads`` being the default download location--this may not be the case on your system) with your Windows username filled in for ``<Name>``:

```sh
cp /c/mnt/Users/<Name>/Downloads/commandlinetools*.zip $HOME/Android/Sdk
cp /mnt/c/Users/<Name>/Downloads/commandlinetools*.zip $HOME/Android/Sdk
```

After that, change to the directory, unzip the archive, and remove it:
Expand Down Expand Up @@ -121,12 +161,23 @@ source ~/.bashrc

(The last line reloads your Bash configuration file so that the variable adjustments above become live in your local terminal).

The ``sdkmanager`` command can now be used to install the necessary packages. Run each of the following commands in succession (you may need to accept licenses for the SDK packages in the same way you would when using Android Studio):
The ``sdkmanager`` command can now be used to install the necessary packages.

**Set the default Java version to JDK-17**

Prior to executing the sdkmanager commands, make sure to set the default Java version to jdk-17 by running the following command:

```sh
sudo update-alternatives --config java
```
Select the number with JDK-17.

Run each of the following commands in succession (you may need to accept licenses for the SDK packages in the same way you would when using Android Studio):

```sh
sdkmanager
sdkmanager --install "platform-tools"
sdkmanager --install "platforms;android-28"
sdkmanager --install "platforms;android-33"
sdkmanager --install "build-tools;29.0.2"
```

Expand Down Expand Up @@ -155,14 +206,40 @@ The Oppia Android repository generally expects to live under an 'opensource' dir

```sh
mkdir $HOME/opensource
cd $HOME/opensource
```

Clone the [oppia-android](https://github.com/oppia/oppia-android) repository into the opensource directory.

```sh
git clone https://github.com/oppia/oppia-android.git
```

From there, follow [these instructions](https://github.com/oppia/oppia-bazel-tools#readme) in order to prepare your environment to support Oppia Android builds.

To configure your development environment and set up essential tools, execute the following setup script from the oppia-android directory.

```sh
scripts/setup.sh
```

### 6. Verifying the build

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 & all other Bazel commands must be run from the root of the ‘oppia-android’ directory otherwise they will fail):

To build, it is necessary to configure JDK 8 as the default. To accomplish this, follow these steps:

**Set Default version to JDK 8**

Prior to executing the build commands, make sure to set the default Java version to jdk-8 by running the following command:

```sh
sudo update-alternatives --config java
```

Select the number with JDK-8

**Build**
```sh
bazel build //:oppia
```
Expand Down

0 comments on commit 39a5b9b

Please sign in to comment.