UE 4.27.2 - How to build for target SDK 33 (or 34) !

As you guys might have also got the notice that new apps must target sdk 33.

I had been banging my head since the past 6 hours playing with gradle versions, aapt2, etc to no avail.

Finally found a viable solution! :slight_smile: Steps:

1. In The SDK Manager:

Install API 33 (you can have others as well, but this is important):

Install build tools 30.0.3 (don’t install any version higher than this, UE4 uses the latest installed version !):

Install ndk 21.4.7075529:

install command line tools 11 (latest for now):

2. In The Unreal Engine Settings:

Make sure to set all 3 of these exactly the same. I am using jdk8 (aka 1.8) which comes default shipped with Android Studio 4.0.0. It is also recommended to use this exact version of studio in the official 4.27 docs. I have not test a higher java version than 8 so I wouldn’t recommend it:

2. Modify an engine file:

Edit WebViewControl.java in:

[YOUR UNREAL ENGINE INSTALL DIRECTORY]\Engine\Build\Android\Java\src\com\epicgames\ue4\WebViewControl.java

comment out (or remove) these 3 lines:

viewer.getSettings().setAppCacheMaxSize(1024*1024*8);   
viewer.getSettings().setAppCachePath("/data/data/com.your.package.appname/cache"‌​);    
viewer.getSettings().setAppCacheEnabled(true);

3. last but not least

Delete these folders:

C:\Users\[YOUR_USERNAME]\.gradle
[YOUR_PROJECT_DIRECTORY]\DerivedDataCache
[YOUR_PROJECT_DIRECTORY]\Intermediate
[YOUR_PROJECT_DIRECTORY]\Saved

Restart engine and build ! :smiley:

10 Likes

Just tested with Target Version 34, it works ! :smiley:

Keep everything the same (including compile version 33), just change the target version to 34.

Note: It is recommended and advised that the compile version is not set lower than the target version. But I’m glad it works fine for this version on my project.

1 Like

Make sure to also add:

android:exported=“true”

to your GameActivity node like this:

Otherwise you might get this error while uploading to playstore:

You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without 'android:exported' property set.

You can also manually add this tag in the manifest through an editor like android studio after the build, useful in case a old plugin which you don’t have access to isn’t using this tag.

2 Likes

If this works, it would be amazing!!! im going to test this out over the next few days and get back to you. Should this work with engine version 4.26? Also, would the save files/storage permissions work? Thanks!

Haven’t tested with 4.26 but works perfect for 4.27.2.

Although I haven’t mentioned this in the post, but you might not want to have anything higher than version 8.0 installed for ‘Android SDK Command line Tools’ since it was recently causing problems for me in Unreal Engine 5. This might not cause any issues on UE4 but just in case.

Sorry, I don’t quite understand what you mean by ‘files/storage permissions’. Are you talking about the 'MANAGE_EXTERNAL_STORAGE' manifest permission that is often required to deploy directly on android device without issues ? Then yes, this shouldn’t make any difference. Just try.

is this work with the new version of android studio? (hedgehog version)

Thank you for the instructions. Was looking of doing this as well. Worked like a charm. Wonderful thing this Community :slight_smile:

1 Like

I did everything in this content after that i can build my game but when i want to run on my Android device; i can’t install the APK file? I’m using UE4

1 Like

For those who set targetsdk to 34 and face this error (my UE version 4.26.1): Android Gradle build error “AAPT2 aapt2-4.1.0-6503028-windows Daemon #0: Unexpected error during link, attempting to stop daemon.”

Checkout the solution here : Android Gradle build error "AAPT2 aapt2-4.1.0-6503028-windows Daemon #0: Unexpected error during link, attempting to stop daemon." - Stack Overflow

To link with sdk34, you actually need to compile with sdk 33 (Not sure if its a bug or not)

You should modify UEDeployAndroid.cs to make string CompileSDKVersion = “33”, either this hard coded way. Or make a new ini in Default Engine.ini [/Script/AndroidRuntimeSettings.AndroidRuntimeSettings] to set this a compile skd version, and read it in C# code.

1 Like

I could packaged the APK-file according to your instructions. But now I have a problem to install this APK on my device :sweat_smile:, neither via Batch-File install, nor manually from Device Storage. When I try to install any of packages, I receive these errors:

Windows Batch File


Manual installation

My packaging settings:



Device developer-mode settings:


(Android 13)

From the adb error, it seems like one or more of your activities/services or broadcast receivers declared in the manifest file are using intent filters and have not explicitly defined the tag android:exported="true". Since you are on android 13, this could certainly be the issue.

If this is the case, I have already provided the solution for this above

Unfortunately the “android:exported” playstore error persists for my 4.27 project… Do you think i should edit some other parameter? I ve done all the steps you mention above… Maybe the grandle or cmake version plays some role? Which one did you use? You kept the old android studio? which version? I ve ran out of ideas… I didn’t have any luck for sdk 33 or 34…

1 Like

You can try my Unreal 4.27.2 build which I updated all Android related stuff and you can use NDK 25 and SDK 32 33 34 etc.

total corruption for my game, had to reinstall 4.27… I think it’s the perfect time to kill myself struggling with this android:exported=true thing so many days, having tried all proposed solutions… maybe i will remake the game with ue5

Hello,

I can build up the app and supply it to Google Play Console without issues.

Tried testing on mobile phones through the internal testing. The app installs, but it crashes as soon as you tap to open.

This is the error log I am getting. It is probably something with the java version, but I’m on the JDK 1.8 as per all the tutorials and answers.
The project is built with 4.26 and I cannot update to newer. I successfully built and published on AppStore for iOS.

Any ideas and help would be awesome. Thanks!

Error log from the phone, tried Android 13 and 14 on Xiaomi. On both, the version I published last year works fine without troubles.

java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of ‘java.lang.invoke.LambdaMetafactory’ appears in /apex/com.android.art/javalib/core-oj.jar)
at b.b.a.a.i.z.h.n.(Unknown Source:31)
at b.b.a.a.i.z.h.f.c(Unknown Source:0)
at b.b.a.a.i.z.h.i.c(Unknown Source:0)
at b.b.a.a.i.z.h.i.b(Unknown Source:0)
at b.b.a.a.i.z.h.i.get(Unknown Source:0)
at b.b.a.a.i.z.h.o.b(Unknown Source:18)
at b.b.a.a.i.z.h.o.get(Unknown Source:0)
at b.b.a.a.i.z.h.m.b(Unknown Source:24)
at b.b.a.a.i.z.h.m.get(Unknown Source:0)
at b.b.a.a.i.v.a.a.get(Unknown Source:15)
at b.b.a.a.i.z.g.b(Unknown Source:10)
at b.b.a.a.i.z.g.get(Unknown Source:0)
at b.b.a.a.i.z.b.b(Unknown Source:18)
at b.b.a.a.i.z.b.get(Unknown Source:0)
at b.b.a.a.i.u.b(Unknown Source:18)
at b.b.a.a.i.u.get(Unknown Source:0)
at b.b.a.a.i.v.a.a.get(Unknown Source:15)
at b.b.a.a.i.e.o(Unknown Source:2)
at b.b.a.a.i.s.c(Unknown Source:4)
at com.google.firebase.datatransport.TransportRegistrar.lambda$getComponents$0(Unknown Source:11)
at com.google.firebase.datatransport.TransportRegistrar$$Lambda$1.create(Unknown Source:0)
at com.google.firebase.components.ComponentRuntime.lambda$new$0(Unknown Source:9)
at com.google.firebase.components.ComponentRuntime$$Lambda$1.get(Unknown Source:4)
at com.google.firebase.components.Lazy.get(Unknown Source:15)
at com.google.firebase.components.AbstractComponentContainer.get(Unknown Source:8)
at com.google.firebase.components.ComponentRuntime.get(Unknown Source:0)
at com.google.firebase.components.RestrictedComponentContainer.get(Unknown Source:10)
at com.google.firebase.messaging.FirebaseMessagingRegistrar.lambda$getComponents$0$FirebaseMessagingRegistrar(Unknown Source:43)
at com.google.firebase.messaging.FirebaseMessagingRegistrar$$Lambda$0.create(Unknown Source:0)
at com.google.firebase.components.ComponentRuntime.lambda$new$0(Unknown Source:9)
at com.google.firebase.components.ComponentRuntime$$Lambda$1.get(Unknown Source:4)
at com.google.firebase.components.Lazy.get(Unknown Source:15)
at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(Unknown Source:48)
at com.google.firebase.FirebaseApp.initializeAllApis(Unknown Source:72)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source:73)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source:2)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source:35)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source:4)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2468)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2433)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:3)
at android.app.ActivityThread.installProvider(ActivityThread.java:7823)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7334)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7067)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2212)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.app.ActivityThread.main(ActivityThread.java:8252)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:559)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)

If you use my Custom build , use the same requirement than 5.3 or 5.4 Android Development Requirements for Unreal Engine | Unreal Engine 5.4 Documentation | Epic Developer Community

I struggled with this for more than a month.

In the end, this is what I did that helped. Only in this place, nowhere else.

My project uses old plugin version and cannot update to 4.27… but just seeing your build should do fine for SDK 34…

(post deleted by author)

anyone know if these settings will still work on 5.4? I don’t want to change my build environment and lose the ability to build for 5.4