Packaging for android fails with gradle error

Hello,
I had a project that worked fine with 4.18. After a while and updating to 4.20, I convert in place my project (bad idea) and I can’t manage to package it anymore. Not sure this has anything to do with the 4.20 but it was the main change.
It seems that the error is linked to gradle as I get:

:app:mergeDebugResourcesC:\Users\J?r?mie\.gradle\caches\transforms-1\files-1.1\play-services-base-11.8.0.aar\ed3fd0fb06d8d84f96fc82cb75dba62a\res\drawable\common_google_signin_btn_text_disabled.xml: error: file not found.
C:\Users\J?r?mie\.gradle\caches\transforms-1\files-1.1\play-services-base-11.8.0.aar\ed3fd0fb06d8d84f96fc82cb75dba62a\res\drawable-hdpi-v4\common_google_signin_btn_icon_dark_normal_background.png: error: file not found.

And this goes on for several files that exists. It ends with some AAPT2 error:

> Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

After opening the log file, I read:

<>c.<PrintExceptionInfo>b__4_1: ==============================================================================
<>c.<PrintExceptionInfo>b__4_0: ERROR: cmd.exe failed with args /c "D:\UE4 Projects\Pumpat_Runner\Intermediate/Android/APK\gradle\rungradle.bat" :app:assembleDebug
<>c.<PrintExceptionInfo>b__4_0:        (see C:\Users\Jérémie\AppData\Roaming\Unreal Engine\AutomationTool\Logs\D+UE4+Projects+UE_4.20\Log.txt for full exception trace)
<>c.<PrintExceptionInfo>b__4_1: 
<>c.<PrintExceptionInfo>b__4_1: BuildException: cmd.exe failed with args /c "D:\UE4 Projects\Pumpat_Runner\Intermediate/Android/APK\gradle\rungradle.bat" :app:assembleDebug
<>c.<PrintExceptionInfo>b__4_1:    à UnrealBuildTool.UEDeployAndroid.RunCommandLineProgramWithException(String WorkingDirectory, String Command, String Params, String OverrideDesc, Boolean bUseShellExecute) dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEDeployAndroid.cs:ligne 1406
<>c.<PrintExceptionInfo>b__4_1:    à UnrealBuildTool.UEDeployAndroid.MakeApk(AndroidToolChain ToolChain, String ProjectName, TargetType InTargetType, String ProjectDirectory, String OutputPath, String EngineDirectory, Boolean bForDistribution, String CookFlavor, Boolean bMakeSeparateApks, Boolean bIncrementalPackage, Boolean bDisallowPackagingDataInApk, Boolean bDisallowExternalFilesDir) dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEDeployAndroid.cs:ligne 3838
<>c.<PrintExceptionInfo>b__4_1:    à UnrealBuildTool.UEDeployAndroid.PrepForUATPackageOrDeploy(FileReference ProjectFile, String ProjectName, DirectoryReference ProjectDirectory, String ExecutablePath, String EngineDirectory, Boolean bForDistribution, String CookFlavor, Boolean bIsDataDeploy) dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEDeployAndroid.cs:ligne 3990
<>c.<PrintExceptionInfo>b__4_1:    à AndroidPlatform.Package(ProjectParams Params, DeploymentContext SC, Int32 WorkingCL) dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\AutomationTool\Android\AndroidPlatform.Automation.cs:ligne 403
<>c.<PrintExceptionInfo>b__4_1:    à Project.Package(ProjectParams Params, Int32 WorkingCL) dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\AutomationTool\Scripts\PackageCommand.Automation.cs:ligne 37
<>c.<PrintExceptionInfo>b__4_1:    à BuildCookRun.DoBuildCookRun(ProjectParams Params) dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:ligne 220
<>c.<PrintExceptionInfo>b__4_1:    à BuildCookRun.ExecuteBuild() dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:ligne 41
<>c.<PrintExceptionInfo>b__4_1:    à AutomationTool.BuildCommand.Execute() dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\AutomationTool\AutomationUtils\BuildCommand.cs:ligne 112
<>c.<PrintExceptionInfo>b__4_1:    à AutomationTool.Automation.Execute(List`1 CommandsToExecute, Dictionary`2 Commands) dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs:ligne 562
<>c.<PrintExceptionInfo>b__4_1:    à AutomationTool.Automation.Process(String[] Arguments, StartupTraceListener StartupListener) dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs:ligne 532
<>c.<PrintExceptionInfo>b__4_1:    à AutomationTool.Program.MainProc(String[] Arguments, StartupTraceListener StartupListener) dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\AutomationTool\Program.cs:ligne 174
<>c.<PrintExceptionInfo>b__4_1:    à AutomationTool.Program.<>c__DisplayClass1_0.<Main>b__0() dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\AutomationTool\Program.cs:ligne 100
<>c.<PrintExceptionInfo>b__4_1:    à AutomationTool.InternalUtils.RunSingleInstance(Func`1 Main) dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\AutomationTool\AutomationUtils\Utils.cs:ligne 725
<>c.<PrintExceptionInfo>b__4_1:    à AutomationTool.Program.Main() dans D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\AutomationTool\Program.cs:ligne 100
<>c.<PrintExceptionInfo>b__4_1: ==============================================================================
Program.Main: AutomationTool exiting with ExitCode=1 (Error_Unknown)

I tried the different solutions from:

From my project settings:

256023-android-sdk.jpg

I tried to package by disabling gradle and using ant (by unchecking the box: enable gradle instead of ant). The packaging then completes only if “For distribution” is unchecked. However, the compiled apk crashes right when opening.

If anyone have any idea, I’m more than willing to give it a shot.

Regards

I had the same issue with my students. the just installed codeworks and they can’t compile the app.
They disable gradle and it compile but doen’t run at all.
In my pc I updated my codeworks to 1R7 and installing:

  • Android Toolchain
  • Android SDK
  • Android API 26/25/24
    It worked just fine. It’s depressing since I can’t figure out what the problem is for them :confused:

Hello, I couldn’t solve this issue directly so I haven’t marked it as “solved” but from what I remember (I did several things), it might have been linked to a path on the hard drive with special characters like “é” or “è”. Had to create a new account on my computer to have a proper path. I think it worked but package was too big, I then needed to disable plugins. What I did was disabling unused plugins one by one and testing as much as possible (that might be a pain to perform, especially with students, so better to try this on your side).