Build Android Gradle problem

Hi people please HELP with this one,

Basically, I’m getting an error below when trying to test a game on Android :

LogPlayLevel: Making .apk with Gradle…
LogPlayLevel: To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: The Gradle Daemon.
LogPlayLevel: Daemon will be stopped at the end of the build stopping after processing
LogPlayLevel: FAILURE: Build failed with an exception.
LogPlayLevel: * Where:
LogPlayLevel: Settings file ‘/Users//Documents/Unreal Projects/MyProject/Intermediate/Android/arm64/gradle/settings.gradle’ line: 9
LogPlayLevel: * What went wrong:
LogPlayLevel: A problem occurred evaluating settings ‘app’.
LogPlayLevel: > AFSProject/gradle.properties (No such file or directory)
LogPlayLevel: * Try:
LogPlayLevel: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
LogPlayLevel: * Get more help at https://help.gradle.org
LogPlayLevel: BUILD FAILED in 1s
LogPlayLevel: Error: ERROR: /bin/sh failed with args -c “"/Users//Documents/Unreal Projects/MyProject/Intermediate/Android/arm64/gradle/gradlew" :app:assembleDebug”
LogPlayLevel: (see /Users//Library/Logs/Unreal Engine/LocalBuildLogs/Log.txt for full exception trace)
LogPlayLevel: AutomationTool executed for 0h 0m 45s
LogPlayLevel: AutomationTool exiting with ExitCode=1 (Error_Unknown)
LogPlayLevel: Completed Launch On Stage: Deploy Task, Time: 12.691273
LogPlayLevel: Error: RunUAT ERROR: AutomationTool was unable to run successfully. Exited with code: 1
PackagingResults: Error: Launch failed! Unknown Error

I just encountered a similar issue.

LogPlayLevel: FAILURE: Build failed with an exception.
LogPlayLevel: * Where:
LogPlayLevel: Settings file '/Users/andreivictor/Work/Unreal Projects/AR_Test/Intermediate/Android/arm64/gradle/settings.gradle' line: 9
LogPlayLevel: * What went wrong:
LogPlayLevel: A problem occurred evaluating settings 'app'.
LogPlayLevel: > AFSProject/gradle.properties (No such file or directory)
LogPlayLevel: * Try:
LogPlayLevel: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
LogPlayLevel: * Get more help at https://help.gradle.org
LogPlayLevel: BUILD FAILED in 24s
LogPlayLevel: Error: ERROR: /bin/sh failed with args -c "\"/Users/andreivictor/Work/Unreal Projects/AR_Test/Intermediate/Android/arm64/gradle/gradlew\" :app:assembleDebug"
LogPlayLevel:        (see /Users/andreivictor/Library/Logs/Unreal Engine/LocalBuildLogs/Log.txt for full exception trace)
LogPlayLevel: AutomationTool executed for 0h 1m 30s
LogPlayLevel: AutomationTool exiting with ExitCode=1 (Error_Unknown)
LogPlayLevel: Completed Launch On Stage: Deploy Task, Time: 28.132378
LogPlayLevel: Error: RunUAT ERROR: AutomationTool was unable to run successfully. Exited with code: 1
PackagingResults: Error: Launch failed! Unknown Error

Try deleting the Android folder in [Your project]/Intermediate
then rebuild.

1 Like

I did try, but it resulted the same error.

I think the problem is the current directory that gradle is in. I added a
System.out.println(afs_outfile.getAbsolutePath())
in my settings.gradle and the output was /Users/andreivictor/.gradle/daemon/6.1.1/AFSProject/gradle.properties, which is clearly wrong.

So what I did to fix this problem is to:

  1. Open settings.gradle
  2. Find new File( and replace with new File(rootProject.projectDir, (Mine had 8 occurrences.)
  3. Rebuild.
1 Like

you haven’t got gradle installed properly
or the jre

you MUST have
Android 4, not latest
sdk 23 + command tools 23(some others work)
NDK 21 (b-e version)
JDK 8 (not 17)
JRE 8 (not latest)
The ndk/sdk/jdk hold specifi tools and libs you need
but you can’t run any of the tools without jre 8 installed.

Hi,
the gradle error gave me a hard time aswell. Eventually i found out the gradle error pops up when you have wrong SDK, NDK and JDK setup. I’ll leave here what helped me to resolve the problem in UE 4.27.2:

Install Android studio 4.0 (Android Studio download archives  |  Android Developers)
In Android studio in SDK Manager - SDK Platforms download all APIs from 33 to 19
In SDK Tools download Build-Tools 29.0.3 and 29.0.2 and download NDK 21.4.7075529. If you have other versions, delete them.

In UE in project settings go to Platforms - Android SDK and set paths for your SDK, NDK and JDK:
Location of Android SDK: C:/NVPACK/android-sdk-windows
Location of Android NDK: C:/NVPACK/android-sdk-windows/ndk/21.4.7075529
Location of JAVA: C:/Program Files/Android/Android Studio/jre (it installs with android studio 4.0)
Set SDK and NDK API Level to android-30

Go to the section Android (in Project settings) and set Minimum SDK version to 21 and Target SDK Version to 30.

After that the gradle error was no longer problem to me. Hope it helps

1 Like

I tried to do this but the file keeps being over-written back to it’s original state
(I kept editing the settings.gradle in the Unreal Projects>‘projectname’ . Can you point me in the right direction? I tried locking the file but that just lead to another error.

You only need one sdk
9(29) or 10(30)
same with the api
you only need one
10Q

You have the location of the JDK set to the location of the JRE
The JRE runs the jvm which allows you to load and use the tools from the jdk
gradle is inside the JDK and runs through the JRE

1 Like

In 5.0.2 engine fork, I changed Engine/Plugins/Runtime/AndroidFileServer/Source/AndroidFileServer/AndroidFileServer_UPL.xml with the following:

Line 233-234:

File afs_infile = new File(rootProject.projectDir, 'gradle.properties')
File afs_outfile = new File(rootProject.projectDir, 'AFSProject/gradle.properties')

Line 252-253:

afs_infile = new File(rootProject.projectDir, 'app/buildAdditions.gradle')
afs_outfile = new File(rootProject.projectDir, 'AFSProject/app/buildAdditions.gradle')

Line 277-278:

afs_infile = new File(rootProject.projectDir, 'app/src/main/AndroidManifest.xml')
afs_outfile = new File(rootProject.projectDir, 'AFSProject/app/src/main/AndroidManifest.xml')

Line 303:

afs_infile = new File(rootProject.projectDir, v)

Line 305:

afs_outfile = new File(rootProject.projectDir, "AFSProject/" + v)
1 Like

Thank you for taking the time to explain this to me! it solved the issue. You’re awesome! have a great day.

Glad that I was able to help. And thanks for coming back to confirm.

I ended up just disabling Android File Server (Project Settings > AndroidFileServer > Use AndroidFileServer) because I can’t keep only one version of the Android SDK installed on my machine (I need the newer ones for other stuff) - and editing an intermediate file is just an awful build process.

I’m having a same kind of issue, AFSProject/gradle.properties (No such file or directory), PLEASE HELP :sob:

YOU CAN HAVE MORE THAN ONE INSTALLED
BUT THEN YOU Have to specify in proj settings
sorry
capslock

Hi CodeCalibre,
Is there an other way, other than forking a custom git build and edit the AndroidFileServer_UPL.xml? I have tried to edit the settings.gradle but as others have suggested, it reverts back to the original at the packaging phase. thanks!

I just use the interface in proj settings
I have had no probs
I laso have had other ndk/sdk installed before and it actually was fine as long as I specified correctly in proj settings