-
Notifications
You must be signed in to change notification settings - Fork 30
Building with Gradle (Windows)
For compilation, three things are required:
- The Java Development Kit (JDK)
- The Android software development kit (SDK)
- The source code
Gradle and the sdkmanager command line tool require the Java Development Kit (JDK) to run. Download the "ready for use" Windows build, and move the folder from inside the ZIP into somewhere. After doing that, your PATH must include the bin directory of the JDK.
To verify that the JDK is properly installed, you can check your version by typing java -version in the Command Prompt.
openjdk version "14" 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)
If you already have a JRE (Java Runtime Environment) install in your machine, Gradle might confuse it with the JDK. To solve that problem, set a JAVA_HOME environment variable to the JDK directory. Then, edit the JDK PATH to point to %JAVA_HOME%\bin.
Get the Android SDK Tools. Download and extract the ZIP into a path without spaces. Note that the target folder must have the tools folder inside it. Set an ANDROID_HOME environment variable to the location where you've extracted the ZIP.
Open a Command Prompt window in the tools\bin folder.
The sdkmanager tool can download packages required for a build. In the Command Prompt, run the following command:
sdkmanager --sdk_root=%ANDROID_HOME% --install "build-tools;29.0.3" "ndk-bundle" "platform-tools" "platforms;android-29" "sources;android-29"
After sdkmanager is done installing packages, set an ANDROID_NDK_HOME environment variable to %ANDROID_HOME%\ndk-bundle.
Accept the license agreements by running the following command:
sdkmanager --sdk_root=%ANDROID_HOME% --licenses
Accept the review prompt:
2 of 2 SDK package licenses not accepted.
Review licenses that have not been accepted (y/N)?
Read the license agreements, and accept them. You will see this message:
All SDK package licenses accepted
Clone this (Lactozilla/SRB2-Android) repository and checkout into the android-port branch.
Navigate to the android folder of the repository, and open a Command Prompt window. Run gradlew build. The Gradle wrapper will download Gradle into your machine, and build the project.
If everything went well, you'll find APKs for two build flavors: gameFull, and gameNoAssets. gameFull is the build flavor that includes the assets required by the game to run (see section 4.) gameNoAssets removes all of those assets before building. If you did not include the game's files in the android/app/src/main/assets folder, the resulting builds will be identical.
For gameFull, you'll find a debug APK in android/app/build/outputs/apk/gameFull/debug/srb2-android-<version>-gameFull-debug.apk, where <version> is the SRB2 version which this APK has been built with. For v2.2.9, it will be v229. You will also find a release (albeit unsigned) APK in android/app/build/outputs/apk/gameFull/debug/srb2-android-<version>-gameFull-release-unsigned.apk.
For gameNoAssets, you'll find a debug APK in android/app/build/outputs/apk/gameNoAssets/debug/srb2-android-<version>-gameNoAssets-debug.apk, and an unsigned release APK in android/app/build/outputs/apk/gameNoAssets/debug/srb2-android-<version>-gameNoAssets-release-unsigned.apk.
If you want to build only a specific flavor, run gradlew assemble<Flavor>, where <Flavor> is the build flavor you want to assemble. The first character of the build flavor has to be uppercase. Note the lack of any spaces between assemble and <Flavor>. For example, to build only the gameFull flavor, run gradlew assembleGameFull. To see all of the build tasks, run gradlew tasks.
If you don't want to use the gradlew Gradle wrapper, you are able to install Gradle manually. You will need to add your Gradle install to your PATH variable.
For any subsequent commands, you can use gradle instead of gradlew. For example, in section 3.1, instead of running gradlew build, run gradle build.
The game's assets (like srb2.pk3) can be packaged with your APKs. They must be placed inside the android/app/src/main/assets folder in the source. Read the README file inside that folder for more detailed information.