Attempting to Pack a UE4.27.2 build to test on Android 14 - PackagingResults: Error: Launch failed! Unknown Error

I’m attempting to build my first mobile game project, and have run into a few hiccups in the setup process:
I am building a mobile game on UE 4.27.2, and the primary device I am looking to initially test on is a Galaxy S24 Ultra, running Android 14.
Setting up Android’s SDK tools, I have the following versions installed and used by the project:
Android SDK - API Level 34
Android NDK - API Level 21
I also have Android Studio Version 4.0 installed with both Android SDK Build 34.0.0, and 30.0.3 installed.

Regardless of what combination I try, or what solution I find online to the issues I’m having, I always end up with the same error:

LogPlayLevel: Execution failed for task ':app:processDebugResources'.
LogPlayLevel: > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
LogPlayLevel:    > AAPT2 aapt2-4.0.0-6051327-windows Daemon #0: Unexpected error during link, attempting to stop daemon.
LogPlayLevel:      This should not happen under normal circumstances, please file an issue if it does.
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 8s
LogPlayLevel: 23 actionable tasks: 1 executed, 22 up-to-date
LogPlayLevel: Error: ERROR: cmd.exe failed with args /c "Z:\[filepath]\Intermediate\Android\arm64\gradle\rungradle.bat" :app:assembleDebug
LogPlayLevel:        (see C:\[filepath]\AppData\Roaming\Unreal Engine\AutomationTool\Logs\Z+Epic+Games+UE_4.27\Log.txt for full exception trace)
LogPlayLevel: AutomationTool exiting with ExitCode=1 (Error_Unknown)
LogPlayLevel: Completed Launch On Stage: Deploy Task, Time: 12.013890
LogPlayLevel: BUILD FAILED
PackagingResults: Error: Launch failed! Unknown Error

Android 14 (SDK 34) builds are required to specify a flag to indicate whether the receiver should be exported to all other apps on the device: either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED, respectively. This changes, however, require minimum NDK r25, which aren’t currently supported in 4.27 nor 4.27Plus. A workaround is to define the flag literal value in the Engine/Build/Android/Java/src/com/epicgames/ue4/GameActivity.java.template:532:

+	private static int RECEIVER_EXPORTED = 2;
	@Override
	public void onStart()
	{
		super.onStart();
		
		if (!BuildConfiguration.equals("Shipping"))
		{
			// Create console command broadcast listener
			Log.debug( "Creating console command broadcast listener");
			consoleCmdReceiver = new ConsoleCmdReceiver(this);
-			registerReceiver(consoleCmdReceiver, new IntentFilter(Intent.ACTION_RUN));
+			registerReceiver(consoleCmdReceiver, new IntentFilter(Intent.ACTION_RUN), RECEIVER_EXPORTED);
		}
//$${gameActivityOnStartAdditions}$$
		Log.debug("==================================> Inside onStart function in GameActivity");
	}

Another important thing to do is to set these parameters in your project’s Config/DefaultEngine.ini:

[/Script/AndroidRuntimeSettings.AndroidRuntimeSettings]
TargetSDKVersion=34
bBuildForArm64=True
bBuildForArmV7=False
SDKAPILevelOverride=matchndk
NDKAPILevelOverride=latest
+ExtraActivityNodeTags=android:exported="true"
bShowLaunchImage=False
bSupportAdMob=False
bPackageDataInsideApk=True

Use NDK r23 (23.0.7599858) and JDK 11 in the SDK setting.

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