Please Select Your Location
Australia
Österreich
België
Canada
Canada - Français
中国
Česká republika
Denmark
Deutschland
France
HongKong
Iceland
Ireland
Italia
日本
Korea
Latvija
Lietuva
Lëtzebuerg
Malta
المملكة العربية السعودية (Arabic)
Nederland
New Zealand
Norge
Polska
Portugal
Russia
Saudi Arabia
Southeast Asia
España
Suisse
Suomi
Sverige
台灣
Ukraine
United Kingdom
United States
Please Select Your Location
België
Česká republika
Denmark
Iceland
Ireland
Italia
Latvija
Lietuva
Lëtzebuerg
Malta
Nederland
Norge
Polska
Portugal
España
Suisse
Suomi
Sverige

Packaging an OpenXR project in Unreal 4.26 and 4.27

Packaging Unreal Projects

In order to distribute your application you would need to package your application with our accepted formats (link to formats).

  • Normally the packaging in Unreal is a complex process that most of the success relies in the proper setup of the next dependencies:
    • Proper Android Studio version installed
    • Proper Java version installed
    • Proper Paths on enviroment variables (Windows)
    • Proper paths reference on Packaging references

If any of the upward points not exactly the proper version for the proper unreal version, the packaging is very likely to fail.  Even if you see information online of some configurations being useful for some Unreal versions, that doesn't mean the same configuration is valid for your intended Unreal Version.  In this lecture we will focus on the proper packaging setup for Unreal 4.26 and 4.27 which will be the final version of Unreal 4 and the most well supported.

For more information about packaging we strongly suggest the official documentation.
https://docs.unrealengine.com/4.27/en-US/Basics/Projects/Packaging/

For more information about android based app development, please read the android app manifiest:
https://developer.android.com/guide/topics/manifest/manifest-intro

Unreal Engine Version 4.26.2 and 4.27.2

Bear in mind that there are a lot of Android Studio, OpenJDK, Build-Tools and SDKs, NDKs newer versions, but Unreal Engine 4.26.2 and 4.27.2 require the outdated versions. (Most issues related to gradle.exe relates to this).

Everything that will be included next is not seen in official documentation and is only found in forums like stack overflow users (special thanks to XClark, to most of this findings) so you may say that Unreal Engine 4.26.2 and 4.27.2 requires the forward steps.

  1. Install Unreal 4.26.2 or 4.27.2.  Older versions may not work with this.
  2. REMOVE ALL VERSIONS OF JAVA's JDK if present.
  3. Make sure you ONLY use Android Studio 4.0 , remove all other versions.

Android Studio 4.0 can be found here: https://developer.android.com/studio/archive

Android Studio 4.0

Accept the license agreement and find the version required.

Unreal Engine Setup

Unreal Engine Project Settings
Packaging Settings
Android Settings

  1. Leave the installation paths for Android Studio AND the SDK as their defaults. ("C:\Program Files\Android\Android Studio" ; "C:\Users[YOUR_NAME]\AppData\Local\Android\Sdk"), where [YOUR_NAME] is replaced with your actual user name folder.
  2. Set your environment variables. Both "User"(top window) and "System"(bottom window) for JAVA_HOME as "C:\Program Files\Android\Android Studio\jre" without the quotes. (This is also the path you will use in Unreal Engine for "JDK")
  3. In Android Studio, SDK Manager, SDK Platforms tab, you MUST have "android-29" (Android 10 Q, API Level 29), but you can install as many SDK versions as you want for other Android devices.
  4. After that, click on the SDK Tools tab, and check the box for "Show Package Details".
  5. You MUST have Android SDK build-tools version "29.0.3" AND NO OTHER VERSION! (Though Gradle STILL might try to install build-tools 29.0.2 at launch, but at least it won't affect the launch this time, which is the important thing.)
  6. You MUST have NDK version "r21d" , which is "21.4.7075529" in the list.
  7. You need the "latest" Android SDK Command-Line Tools (version 5.0).
  8. You MUST have CMake version "3.10.2.4988404".
  9. You MUST have the Android SDK Platform-Tools.
  10. Add the Android Emulator, and if you have an AMD processor, install the hypervisor driver for it. If you have an Intel processor, install the "Intel X86 Emulator Accelerator".
  11. Google Play options could be optional.
  12. Click on Apply, let everything download and finish, then click finish/close.
  13. REBOOT.
  14. Go to the Unreal Editor's install location. Under "UE_4.27 > Engine > Extras > Android", execute the SetupAndroid.bat file. It "should" complete successfully. When it does, press any key to close the window.
  15. Open an existing Unreal project or start a new one. ("Games > Virtual Reality" recommended, since has all OpenXR features ready)

In case you have an existing project:

BEFORE you open it, go into your project folder and DELETE the "Intermediate", "Saved" and "DerivedDataCache" folders.

THEN delete the ".gradle" folder from "C:\Users[YOUR_NAME]", replacing [YOUR_NAME] with your actual user name folder.

Optionally, reboot, if you want to, but it's not necessary.

Final Setup

  • Once the project is opened, click "Edit > Project Settings". Scroll down to "Platforms > Android SDK". Copy the paths into the appropriate fields:
    • Location of Android SDK: C:/Users/[YOUR_NAME]/AppData/Local/Android/Sdk
    • Location of Android NDK: C:/Users/[YOUR_NAME]/AppData/Local/Android/Sdk/ndk/21.4.7075529
    • Location of JAVA: C:/Program Files/Android/Android Studio/jre
    • Obviously change [YOUR_NAME] to your user name folder again, and BE MINDFUL of the slash direction, when pasting the paths into the fields: Use the forward slash " / ".
  • Important fields:
    • Under SDK API Level, use "android-29" without the quotes.
    • Under NDK API Level, use "latest" without the quotes.
    • Scroll up to "Platforms > Android" in the Project Settings, and make sure your "android package name" is set.
    • Also make sure the "Target API" is set to 29 .
  • Then scroll down to "Build" and make sure "Support arm64" is checked, in case you need a 64bit app (depends on the platform that you are looking for).
  • Finally check "Support Vulkan" , as Android Vulkan is more stable and powerful.
  • Click "Edit > Plugins". Under "Virtual Reality", make sure that Open XR and SteamVR plugins are checked.

You should be able to follow the rest of the docs on the official pages from here without much issue.
https://docs.unrealengine.com/4.27/en-US/Basics/Projects/Packaging/

But in case you want to test it quickly, best way is to package the game as Android ASTC, which is the minimal version that will give you the least issues at this point.

Build Android Game

You should be able to see the build project in the folder you choose (in this particular example I also added OBB files to the packaging, but they are not needed to make this work).

Package Files