cancel
Showing results for 
Search instead for 
Did you mean: 

How to build and deploy a UE4 project on the Oculus Quest from Linux

Anonymous
Not applicable
It started out as a joke, but I've managed to set up a PC with Ubuntu 18.04.2 LTS installed and have successfully built, deployed and run my game on the Quest.

If you're thinking of doing the same, this is a sort of guide. There are actual (and official) guides on how to build and run UE4 on Linux, and how to set up Android development on Linux:

These are both very good guides and you should follow them.

And you'll probably need this one too, especially if your game is a C++ (rather than Blueprint-only) project:

What I'm writing here is basically to fill in some gaps in the documentation, and hopefully save someone else several hours of Googling and reinstalling Ubuntu, etc... If you're a Linux guru, you probably already know all of this. I'm basically the opposite of a Linux guru, but I've had some experience from using the Terminal in Mac OS X in the past. So this guide assumes that you have some experience using the Terminal in OS X / Linux, or are at least very experienced with using the command prompt in Windows.

Let's start.

What versions to use, and what problems you'll face
As far as I know, the following works with:
- the Oculus branch of UE4.21.2
- Ubuntu 18.04.2 LTS.

This is pretty important - I started with a newer version of Ubuntu (19.04) but that turned out to be a huge bag of hurt; lots of weird bugs, and some underlying changes preventing you from installing some libraries. This might work with other versions of Ubuntu (or Linux, in general), but there are too many variables and things will probably go wrong.

I'm not using 4.22 because there was a bug with spawning motion controllers in C++, and I wasn't going to modify the engine source, since the rest of my team are using the vanilla version of UE4 from the Epic Games Launcher.

The main issues when trying to deploy and run games on the Quest are:
- UE4.21 (and UE4.22) for Linux ships with CodeWorksforAndroid-1R6u1, rather than the newer -1R7u1
- The CodeWorksforAndroid installer relies on the deprecated libpng12 library.
- Even if you get the newer CodeWorksforAndroid installer directly from Nvidia, it has the wrong NDK and is missing the minimum required Platform SDK-tool version.
- You may not have set the Java Development Kit (JDK) correctly.

The good news is that, if you've successfully set up a Windows 10 PC to build and deploy to the Quest before, a lot of this will be very familiar.

The extra steps (to get it building on Linux)
So, assuming you have already followed the above two tutorials and have successfully build the Oculus branch of UE4.21.2 on Ubuntu, and have set up your project to build and run from QT Creator, and can already edit your game in UE4Editor, you now need to do the following:

1. Install libpng12-0 - it is required by the CodeWorksforAndroid installer. (This step was a real pain in 19.04 and I ended up using some random person's repackaged installers because none of the usual methods worked). Go to https://packages.ubuntu.com/xenial/amd64/libpng12-0/download, click on the download link and let the Ubuntu Software GUI handle the installation.

2. Download CodeWorks-1R7-linux-x64_b166.deb (https://developer.nvidia.com/gameworksdownload#?dn=codeworks-for-android-1r7). You will unfortunately need to sign up for an Nvidia Developer Membership.

3. Start the Codeworks installer from the Terminal (open a Terminal window in your download directory and type "sh ./CodeWorks-1R7-linux-x64_b166.run"). It will ask if you want to install "Dependencies" such as java-8-oracle and dos2unix. Select "no". In the next screen, use the default installation directory for NVPACK (usually "/home/<username>/NVPACK"), unless it absolutely has to be somewhere else. If so, take note of where it is - you'll need it.

4. Click on the "Standard" radio button (if it isn't already selected) for a Standard CodeWorks installation. After that, scroll down to Android ToolChain-->AndroidNDK and click on the "install 15c" text. A pop-up menu will appear. Select "no action". We're doing this because our setup requires an OLDER version of the NDK (version 14b, which you'll download separately later). Click "Next", accept all the license agreements and wait for the packages to install.

5. After CodeWorks is installed, you need to go to "../NVPACK/android-sdk-linux/tools", open a Terminal window there and type "sh android". This brings up another installer GUI for platform tools. Select Android SDK Build-tools 26.0.2 and install that. (Strangely, the default CodeWorks installation only gives you 26.0.1, which doesn't meet the minimum requirements of either the NDK or Gradle, I can't remember).

6. Download android-ndk-r14b-linux-x86_64.zip from https://developer.android.com/ndk/downloads/older_releases.html, and extract the folder into your NVPACK folder. At the end of this, you should have a ../NVPACK/android-ndk-r14b folder.

7. At this point, you should go back to your UE4.21 root folder and run Setup.sh again (this is similar to Setup.bat on Windows). You should already know how to do this by now, but if you don't, open a Terminal window in your UnrealEngine4.21 folder and type "./Setup.sh". This will install all the 3rd party libraries required for making Android / Quest builds (in fact, this is something you also have to do on Windows, but nobody sees to mention it).

8. Now it's time to install Java. Specifically, OpenJDK 8. You could install the Oracle version instead, but this works fine. To begin, simply open a Terminal window and type "sudo apt install openjdk-8-jdk" and wait for it all to install.

9. Set your $JAVA_HOME enviroment variable to point to the right spot. Type "sudo gedit /etc/environment" to edit your environment variables in a text editor. Add JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64" to the end of the file, and save it. Back in the terminal, type ". /etc/environment" (yes, with the dot and space after it) to activate it for this session (it should automatically work for all subsequent sessions).

10. If you type "java -version" in the Terminal, it should now show you what version you have installed and selected.

11. As an extra step, just to check that you've actually got the Java Development Kit (JDK) installed (and not just the Java Runtime Environment - or JRE), go to "/usr/lib/jvm/java-8-openjdk-amd64/bin" and make sure there's a file there called "javac" (which is the Java compiler). If you don't then I've screwed up somewhere and you need to figure out how to install the JDK properly.

12. Back in the UE4 Editor, open Project Settings and go to Platforms-->Android. Make sure the Minimum and Target SDK versions are 25 (and, of course, make sure you've accepted the SDK license).

13. No go to Platforms-->Android SDK and set the location of the SDK, NDK, ANT and Java. If you installed CodeWorks in the default location, then they should be:
    - <YourHomeDirectory>/NVPACK/android-sdk-linux/
    - <YourHomeDirectory>/NVPACK/android-ndk-r14b/
    - <YourHomeDirectory>/NVPACK/apache-ant-1.8.2/
    - /usr/lib/jvm/java-8-openjdk-amd64/

Set the SDK API level to "android-26" and the NDK API level to "latest".

14. Unless I've missed a step (and let me know if I have), you should now be able to build and deploy to the Quest from an Ubuntu machine~! Once you've made your builds, you'll find that deploying it is very similar to doing it in Windows (there's an .sh file instead of a .bat file to deploy your APK to the Quest. You'll also find that all the "adb" commands work as they did in the Windows Command Prompt).

I expect precisely zero people will try this. But if you do, good luck~!

Other things I've learnt from this:
1. When you're installing QT Creator, make sure you select a version of Qt (e.g. Qt 5.13.0) in the "Select Components" screen, otherwise you won't be able to set up your UE4 and game project files.

2. If you're using an SVN repo, make sure you have SVN installed ("sudo apt-get update" followed by "sudo apt-get install subversion")otherwise the UE4 editor won't be able to hook up to your workspace and repo. I'm using SmartSVN as a GUI-based SVN client, which is completely self-contained and doesn't install SVN itself into the usr/bin folder.

3. If you're using an Nvidia graphics card, you need at least nvidia-driver-4xx series for Vulkan support, I think. Otherwise, you'll have to run the editor in OpenGL. In Ubuntu 18.04, the 4xx-series drivers aren't listed in the Software & Updates --> Additional Drivers tab by default, so I had to install them via the Terminal. I just followed the guide on "Installing the latest Nvidia driver" from here: https://www.maketecheasier.com/install-nvidia-drivers-ubuntu/

4. If you're also getting weird flickering on the screen like I was, launch the Nvidia X Server Settings, go to PowerMizer and set the preferred mode to "Prefer Maximum Performance" - the power saving features seem to cause the flickering, and this happened on a couple of 4xx series drivers I've tried. I'm using a cheap NVidia GTX 1050, which is good enough for running the UE4 Editor.







0 REPLIES 0