Packing for Android in 5.3 targets Gradle 7.4.2 but pulls 7.5

I’m trying to build on Android, with UE 5.3 from the engine source.

I’ve got my setup, and it’s worked for 5.2 and back but seems to run into an issue with Gradle in 5.3.

Could not resolve com.android.tools.build:gradle:7.4.2.

This was the only informative error message. It’s weird though because the logs indicate that it’s trying to use Gradle 7.5, but I’ve got nothing on my machine that has installed Gradle 7.5 nor specifically lists Gradle 7.5.

I’ve run the SetupAndroid.bat files, checked every bit of documentation and googled my issue into the ground. I’ve uninstalled and reinstalled Android Studio multiple times, checked every environment variable.

I’m at a complete loss, especially since I’ve been able to successfully build in 5.2, all the way back to 4.26.

13 Likes

Get the same error using source build from ue5-main, version: [c55a60b]

UATHelper: 打包 (Android (ASTC)): ====2023-08-23-周三 16:23:09====PERFORMING FINAL APK PACKAGE OPERATION=====arm64===========================================
UATHelper: 打包 (Android (ASTC)): Copying C:\Code\UnrealProjects\TestAndroid1\Intermediate\Android\arm64\AndroidManifest.xml to C:\Code\UnrealProjects\TestAndroid1\Intermediate\Android\arm64\gradle\app\src\main\AndroidManifest.xml
UATHelper: 打包 (Android (ASTC)): Creating rungradle.bat to work around commandline length limit (using unused drive letter Z:)
UATHelper: 打包 (Android (ASTC)): Making .apk with Gradle…
UATHelper: 打包 (Android (ASTC)): To honour the JVM settings for this build a single-use Daemon process will be forked. See The Gradle Daemon.
UATHelper: 打包 (Android (ASTC)): Daemon will be stopped at the end of the build
UATHelper: 打包 (Android (ASTC)): FAILURE: Build failed with an exception.
UATHelper: 打包 (Android (ASTC)): * What went wrong:
UATHelper: 打包 (Android (ASTC)): A problem occurred configuring root project ‘app’.
UATHelper: 打包 (Android (ASTC)): > Could not resolve all files for configuration ‘:classpath’.
UATHelper: 打包 (Android (ASTC)): > Could not resolve com.android.tools.build:gradle:7.4.2.
UATHelper: 打包 (Android (ASTC)): Required by:
UATHelper: 打包 (Android (ASTC)): project :
UATHelper: 打包 (Android (ASTC)): > No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute ‘org.gradle.plugin.api-version’ with value ‘7.5’ but:
UATHelper: 打包 (Android (ASTC)): - Variant ‘apiElements’ capability com.android.tools.build:gradle:7.4.2 declares a library, packaged as a jar, and its dependencies declared externally:
UATHelper: 打包 (Android (ASTC)): - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
UATHelper: 打包 (Android (ASTC)): - Other compatible attribute:
UATHelper: 打包 (Android (ASTC)): - Doesn’t say anything about org.gradle.plugin.api-version (required ‘7.5’)
UATHelper: 打包 (Android (ASTC)): - Variant ‘javadocElements’ capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
UATHelper: 打包 (Android (ASTC)): - Incompatible because this component declares documentation and the consumer needed a library
UATHelper: 打包 (Android (ASTC)): - Other compatible attributes:
UATHelper: 打包 (Android (ASTC)): - Doesn’t say anything about its target Java version (required compatibility with Java 8)
UATHelper: 打包 (Android (ASTC)): - Doesn’t say anything about its elements (required them packaged as a jar)
UATHelper: 打包 (Android (ASTC)): - Doesn’t say anything about org.gradle.plugin.api-version (required ‘7.5’)
UATHelper: 打包 (Android (ASTC)): - Variant ‘runtimeElements’ capability com.android.tools.build:gradle:7.4.2 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
UATHelper: 打包 (Android (ASTC)): - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
UATHelper: 打包 (Android (ASTC)): - Other compatible attribute:
UATHelper: 打包 (Android (ASTC)): - Doesn’t say anything about org.gradle.plugin.api-version (required ‘7.5’)
UATHelper: 打包 (Android (ASTC)): - Variant ‘sourcesElements’ capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
UATHelper: 打包 (Android (ASTC)): - Incompatible because this component declares documentation and the consumer needed a library
UATHelper: 打包 (Android (ASTC)): - Other compatible attributes:
UATHelper: 打包 (Android (ASTC)): - Doesn’t say anything about its target Java version (required compatibility with Java 8)
UATHelper: 打包 (Android (ASTC)): - Doesn’t say anything about its elements (required them packaged as a jar)
UATHelper: 打包 (Android (ASTC)): - Doesn’t say anything about org.gradle.plugin.api-version (required ‘7.5’)
UATHelper: 打包 (Android (ASTC)): * Try:
UATHelper: 打包 (Android (ASTC)): > Run with --stacktrace option to get the stack trace.
UATHelper: 打包 (Android (ASTC)): > Run with --info or --debug option to get more log output.
UATHelper: 打包 (Android (ASTC)): > Run with --scan to get full insights.
UATHelper: 打包 (Android (ASTC)): * Get more help at https://help.gradle.org
UATHelper: 打包 (Android (ASTC)): BUILD FAILED in 3s
UATHelper: 打包 (Android (ASTC)): cmd.exe failed with args /c “C:\Code\UnrealProjects\TestAndroid1\Intermediate\Android\arm64\gradle\rungradle.bat” :app:assembleDebug
UATHelper: 打包 (Android (ASTC)): (see D:\Code\GitHub\UnrealEngine\Engine\Programs\AutomationTool\Saved\Logs\Log.txt for full exception trace)
UATHelper: 打包 (Android (ASTC)): AutomationTool executed for 0h 0m 34s
UATHelper: 打包 (Android (ASTC)): AutomationTool exiting with ExitCode=1 (Error_Unknown)
UATHelper: 打包 (Android (ASTC)): BUILD FAILED
PackagingResults: Error: Unknown Error

I experienced the same thing and fixed it by changing the Java version to 17.

1 Like

how did you change it? from where? please provide the steps to help the people

I did actually manage to get it building.
The Android documentation going into 5.3 will need quite a bit of overhauling to explain the bigger issue.

In the SetupAndroid.bat, it’s actually now setting pretty much all of the environment variables for you instead of you having to do them yourself, with the exception of your ANDROID_HOME is set.

The default setup will only support Android 32 and newer. Because of this, you will need to install Java 11 and make sure that JAVA_HOME is pointing to that location.
Mine is C:\Program Files\Android\Android Studio\jbr. Also, I know the Android setup page tells you do change SetupAndroid.bat to use the path to 8.0 instead of latest, but make sure you leave it on latest.

You can run the SetupAndroid.bat with parameters for older versions if you’d like, and if you do, make sure your JAVA_HOME is pointing to the correct place.

I hope this helps.

1 Like

it worked for me the same setup as ue5.2. i changed nothing but jdk to 17

2 Likes

My 5.2 setup did not work going into 5.3. But my environment is also a little messy as I have to constantly move between UE5 and UE4 and there are things that just don’t get along. 5.2 is when the SetupAndroid.bat changed, but I guess in some cases it played just fine because the Gradle plugin requirements?

if you change between ue5 and ue4 then yeah your case might be diff than mine. i just changed jdk to 17 and it worked fine

1 Like

Changing the JDK to 17 worked for me (UE_5.3).

Followed all steps on the documentation. After that I get the “Could not resolve com.android.tools.build:gradle:7.4.2” error.

So I changed the SetupAndroid.bat to latest instead of 8.0

In AndroidStudio I installed Command-line Tools (latest) 11.0
SDK Manager/SDK Tools/ Also needed to check Show Package Details
Don’t know if that step is necessary to be honest

Installed JDK17

Changed the JAVA_HOME environment variable to the install location of the JDK17
(mine was "C:\Program Files\Java\jdk-17")

Run the SetupAndroid.bat

Now I can package Android normally.

15 Likes

This helps explain the issue: How to Set Up Android SDK and NDK For Your Unreal Engine Development Environment | Unreal Engine 5.3 Documentation

I have the same issue in UE5.3.
I tryed the documentation from UE about 5.3 setup here
And I tryed to use my 5.2 setup (wich was working)with java home edited to java jdk17 but the error is still there.
Could someone share their working setup in project settings like this one ? and maybe their environment variables in link with unreal (Java-home and cie).

I think my issue is from the different versions I have with java JDK/SDK/NDK/gradle/whatever.

It seems you haven’t updated and linked the new JAVA location. The new one should start with ‘jbr’ instead of ‘jdk’ according to the documentation

oh and i almost forgot - the environment variables for NDKROOT must match the NDK location in your project settings.
image

i think SetupAndroid.bat may have actually determined this NDK version for me and overwritten the env variables, so i ended up copying the path from here and then pasting that into unreal. (I’m not certain but don’t want to undo any part of my working setup at this time)

Here are my settings that solved this issue in case anyone wants to try mine. I was building for Oculus Quest Pro in Unreal 5.3.


image

2 Likes

what if we want to target the newest 34 ? Why does it only work with 29???

Hi. What versionof JAVA you use?

Thank you for sharing. hmm interesting… I don’t have a jbr folder :roll_eyes:

is this still working for you? Are you on the Meta Source Engine version of 5.3?

a quick solution for me was this:

  1. download jdk 17 here: Java Archive Downloads - Java SE 17 (the zip format is ok)
  2. extract the zip file and rename the folder to “jre”
  3. go in Android studio installation folder where is most probably supposed you have the current jre (it should be: C:\Program Files\Android\Android Studio) and rename the “jre” folder you currently have to “jre-old” (useful if you need to roll back)
  4. cut and paste the ‘jre’ folder you have from step 2 in Android Studio folder
  5. try to package again

It worked for me.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.