Manually Updating Gradle in Unreal Engine (draft)

SO my engine gradle versions were mismatched when build a project for oculus quest, but that was by default by epic. Not sure if I needed to go this extreme for this, but here’s what I did: – Update the gradle version in [EngineVersion]\Engine\Build\Android\Java\gradle\build.gradle

'com.android.tools.build:gradle:4.1.2'

– Update the gradle distribution in [EngineVersion]\Engine\Build\Android\Java\gradle\gradle\wrapper\gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

– Update the gradle distribution in [EngineVersion]\Engine\Plugins\Runtime\GooglePAD\Source\ThirdParty\gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

– Added empty baseBuildAdditions.gradle and buildscriptAdditions.gradle files to satisfy the build script – Ran [EngineVersion]\Engine\Build\Android\Java\gradle\gradlew.bat --clean – Ran [EngineVersion]\Engine\Build\Android\Java\gradle\gradlew.bat That force updated my gradle install, but this wasn’t enough because my intermediate folder was still reporting that somewhere an older gradle version was being referenced so what I did next was: – Made Extra_UPL.xml in [ProjectName]/Source/[ProjectName]

<?xml version="1.0" encoding="utf-8"?>
<!-- XML -->
<root xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Gradle Properties -->
<gradleProperties>
<insert>
ANDROID_BUILD_TOOLS_GRADLE_VERSION=com.android.tools.build:gradle:4.1.2
ANDROID_TOOLS_BUILD_GRADLE_VERSION=com.android.tools.build:gradle:4.1.2
</insert>
</gradleProperties>
</root>

– Updated [ProjectName].build.cs

       var manifest_file = Path.Combine(ModuleDirectory, "Extra_UPL.xml");
       AdditionalPropertiesForReceipt.Add(new ReceiptProperty("AndroidPlugin", manifest_file));

– Ran build, success

Now, this can still possibly have bugs because when I go into my gradle.properties in the [ProjectName]\intermediate\Android\[TargetVersion]\gradle folder, I now see 2 listings for ANDROID_TOOLS_BUILD_GRADLE_VERSION. One with the old version and one with the version we have provided. I’m guessing the build process saw both and took the newer version. I’d like to find out where that old version is being injected from, but I don’t know how I could find that.

org.gradle.daemon=false
org.gradle.jvmargs=-XX:MaxHeapSize=4096m -Xmx9216m
android.injected.testOnly=false
COMPILE_SDK_VERSION=30
BUILD_TOOLS_VERSION=31.0.0 rc4
PACKAGE_NAME=com.[CompanyName].[ProjectName]
MIN_SDK_VERSION=23
TARGET_SDK_VERSION=29
STORE_VERSION=1
VERSION_DISPLAY_NAME=1.0
OUTPUT_PATH=[PathToProject]/Binaries/Android
OUTPUT_FILENAME=[ProjectName]-Android-Shipping-arm64.apk
OUTPUT_BUNDLEFILENAME=[ProjectName]-Android-Shipping-arm64.aab
OBB_FILECOUNT=1
OBB_FILE0=[PathToProject]/Saved/StagedBuilds/Android_ASTC.obb
ANDROID_TOOLS_BUILD_GRADLE_VERSION=com.android.tools.build:gradle:3.5.3
BUNDLETOOL_JAR=[PathToEngine]/Engine/Build/Android/Prebuilt/bundletool/bundletool-all-0.13.0.jar
GENUNIVERSALAPK_JAR=[PathToEngine]/Engine/Build/Android/Prebuilt/GenUniversalAPK/bin/GenUniversalAPK.jar
ANDROID_BUILD_TOOLS_GRADLE_VERSION=com.android.tools.build:gradle:4.1.2
ANDROID_TOOLS_BUILD_GRADLE_VERSION=com.android.tools.build:gradle:4.1.2
            android.useAndroidX=true
            android.enableJetifier=true
        
STORE_FILE= REDACTED
STORE_PASSWORD= REDACTED
KEY_ALIAS= REDACTED
KEY_PASSWORD=REDACTED

Leave a Reply