How can I add "android:exported" attribute to SplashActivity part in AndroidManifest.xml with an API-31 project?

I cannot deploy an project whose API Level is 31 on Android in accordance with this requirement.

[Background]
Packaging a vanilla project for test has succeeded with editing some files (explain it later), but I cannot deploy it on device.
The error part when launching the game is as below:

Summary

LogPlayLevel: Failure [DELETE_FAILED_INTERNAL_ERROR]
LogPlayLevel: Took 0.1758856s to run adb.exe, ExitCode=1
LogPlayLevel: Running: C:\Users\username\AppData\Local\Android\Sdk\platform-tools\adb.exe -s 27191JEGR25829 install “C:\Users\username\Documents\Unreal Projects\MyProject2\Binaries/Android\MyProject2-arm64.apk”
LogPlayLevel: adb: failed to install C:\Users\username\Documents\Unreal Projects\MyProject2\Binaries/Android\MyProject2-arm64.apk: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl666559365.tmp/base.apk (at Binary XML file line #55): com.epicgames.ue4.SplashActivity: Targeting S+ (version 31 and above) requ
ires that an explicit value for android:exported be defined when intent filters are present]
LogPlayLevel: Performing Streamed Install
LogPlayLevel: Took 3.7226355s to run adb.exe, ExitCode=1
LogPlayLevel: Error: ERROR: Installation of apk ‘C:\Users\username\Documents\Unreal Projects\MyProject2\Binaries/Android\MyProject2-arm64.apk’ failed: [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl666559365.tmp/base.apk (at Binary XML file line #55): com.epicgames.ue4.SplashActivity: Targeting S+ (version 31 and a
bove) requires that an explicit value for android:exported be defined when intent filters are present]
LogPlayLevel: Performing Streamed Install
LogPlayLevel: (see C:\Users\username\AppData\Roaming\Unreal Engine\AutomationTool\Logs\D+UE_4.27\Log.txt for full exception trace)
LogPlayLevel: AutomationTool exiting with ExitCode=35 (Error_AppInstallFailed)
LogPlayLevel: Completed Launch On Stage: Deploy Task, Time: 61.801483
LogPlayLevel: BUILD FAILED
PackagingResults: Error: 起動に失敗しました! Failed to Install app

To fllow the instruction, I found the code creating the xml in Engine\Source\Programs\UnrealBuildTool\Android\UEDeployAndroid.cs.

Summary
			if (bShowLaunchImage)
			{
				// normal application settings
				Text.AppendLine("\t\t<activity android:name=\"com.epicgames.ue4.SplashActivity\"");
				Text.AppendLine("\t\t          android:label=\"@string/app_name\"");
				Text.AppendLine("\t\t          android:theme=\"@style/UE4SplashTheme\"");
				Text.AppendLine("\t\t          android:launchMode=\"singleTask\"");
				Text.AppendLine(string.Format("\t\t          android:screenOrientation=\"{0}\"", Orientation));
				Text.AppendLine(string.Format("\t\t          android:debuggable=\"{0}\">", bIsForDistribution ? "false" : "true"));
				Text.AppendLine("\t\t\t<intent-filter>");
				Text.AppendLine("\t\t\t\t<action android:name=\"android.intent.action.MAIN\" />");
				Text.AppendLine(string.Format("\t\t\t\t<category android:name=\"android.intent.category.LAUNCHER\" />"));
				Text.AppendLine("\t\t\t</intent-filter>");
				Text.AppendLine("\t\t</activity>");
				Text.AppendLine("\t\t<activity android:name=\"com.epicgames.ue4.GameActivity\"");
				Text.AppendLine("\t\t          android:label=\"@string/app_name\"");
				Text.AppendLine("\t\t          android:theme=\"@style/UE4SplashTheme\"");
				Text.AppendLine(bAddDensity ? "\t\t          android:configChanges=\"mcc|mnc|uiMode|density|screenSize|smallestScreenSize|screenLayout|orientation|keyboardHidden|keyboard\""
											: "\t\t          android:configChanges=\"mcc|mnc|uiMode|screenSize|smallestScreenSize|screenLayout|orientation|keyboardHidden|keyboard\"");
			}

[WHAT I DID]

  1. Decapitalized the packange name. I read it must be lower case somewhere on the Internet.
    com.YourCompany.[PROJECT] → com.comp.prj

  2. Renamed two “d8” files to “dx”. The previous errors are that they were missing:

  • AppData\Local\Android\Sdk\build-tools\31.0.0\d8.bat
  • AppData\Local\Android\Sdk\build-tools\33.0.0\lib\d8.jar
  1. Raised gradle version 3.5.3 to 4.0.0 by editing UE_4.27\Engine\Build\Android\Java\gradle\build.gradle.
    I confirmed that an API 31 project can be deployed on Android Studio, and just imitated the gradle. This change was affected, but probably no meaning for this problem.

[SETTINGS]
UE4.27 and Android Studio 4.0.

Project Settings:
image

I set android:exported=“ture” for UE4.GameActivity, of coure.

[Questions]
I think it would be successful or get just some similar errors for other tags like activity if I added one line Text.AppendLine(“\t\t android:exported="true"”); into com.epicgames.ue4.SplashActivity part and could build it.

So my questions are:

  1. Are my procedure and estimate correct?

  2. If 1. is yes, is it possible to build only C# code on UE4 engine? I don’t want to take much time to fully build UE4.

  3. If 1. is no, please tell me a right method.
    Even if 1. is yes, any other solution will be very welcome.

Thanks in advance.

if you are using a engine from source … there is a solution here Pack a game for android without installing android studio (+update android 12)

It turned out that it is unnecessary to edit UEDeployAndroid.cs . To avoid crash on startup, unchecking the item like display splash image (idk the sentence in English) in UE4 settings is enough. When I need splash screen, I will create the one on ue4.

Then, you will get the error “Failed to open descriptor file”. I also found the way around this problem. The main reason causing this problem is your app’s accessibility to the other files in Android. So, you need to give your UE4 application more authority. Follow this way:

  1. Deploy project with bat file created by files->package project->Android->some platform.
  2. Enable all accessibilities in settings on your Android or with command line.

This is a bit tedious, but it will work for your apps :slight_smile:

2 Likes

Worked Thanks man! You save my work

1 Like

After adding property to activity settings dont forget to delete Android folder and Build/Android in Intermediate folder of your project

Hi, updating.
You can add splashscreen with Unreal Plugin Language | Unreal Engine 4.27 Documentation.
This extension enables us to customize the AndroidManifest.xml. Go check the link.
Also, I found the so useful plugin Sovahero/PluginMobileNativeCode (github.com) that you can display splash screen and even execute Java code with it. I strongly recommend you use it🤞.

Specifically, Intermediate/Build/Android/.gradle, I remember.
You may have to delete this directory when compiling, so it is easy to do so in build.cs. (it disturbed compiling everytime in my case)

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