Android packaging fails with errors in GameActivity.java

Hi everyone,

When packaging for Android on UE5.3 there are no errors.
When packaging for Android on UE5.4 it fails with errors in GameActivity.java:

UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:782: error: cannot find symbol
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):          activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):                         ^
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   symbol:   method runOnUiThread(<anonymous Runnable>)
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:1061: error: cannot find symbol
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):          activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):                         ^
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   symbol:   method runOnUiThread(<anonymous Runnable>)
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:1086: error: cannot find symbol
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):          activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):                         ^
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   symbol:   method runOnUiThread(<anonymous Runnable>)
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:1152: error: cannot find symbol
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):      activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):                     ^
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   symbol:   method runOnUiThread(<anonymous Runnable>)
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:1173: error: cannot find symbol
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):      activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):                     ^
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   symbol:   method runOnUiThread(<anonymous Runnable>)
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:1193: error: cannot find symbol
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):      activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):                     ^
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   symbol:   method runOnUiThread(<anonymous Runnable>)
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Z:\app\src\main\java\com\epicgames\unreal\GameActivity.java:1235: error: cannot find symbol
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):          activityContext.runOnUiThread(new Runnable()
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):                         ^
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   symbol:   method runOnUiThread(<anonymous Runnable>)
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)):   location: variable activityContext of type ContextWrapper
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Note: Some input files use or override a deprecated API.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Note: Recompile with -Xlint:deprecation for details.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): 7 errors
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): > Task :app:compileReleaseJavaWithJavac FAILED
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): FAILURE: Build failed with an exception.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): 69 actionable tasks: 69 executed
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): * What went wrong:
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): Execution failed for task ':app:compileReleaseJavaWithJavac'.
UATHelper: Packaging (Android (Multi:ASTC,DXT,ETC2)): > Compilation failed; see the compiler error output for details.

I have a C++ project, so when I comment out the following lines from .Target.cs it works without errors but there is no AdMob support:

		if (Target.Platform == UnrealTargetPlatform.Android)
		{
			ExtraModuleNames.Add("OnlineSubsystemGooglePlay");
			ExtraModuleNames.Add("OnlineSubsystem");
			ExtraModuleNames.Add("AndroidAdvertising");
		}

Does anyone have any idea how to package for Android on UE5.4, with AdMob support?

Thanks.

1 Like

you got any solution

No, the problem still persists, as described above.

Edit: I just updated to 5.4.2 and I get the same errors. Even commenting out the lines in Target.cs causes the errors. Any ideas?

you got solution bro

I am facing the same issue still.

If Anyone Face This PRoblem in unreal 5.4 just replace the AdvertisingPlugin inside runtime with older engine version .For me i repplcae with UE5.2 and it show ad

Are you using Android or IOS? The only plugin I have in Advertising (Runtime) is IOSTapJoy.

android

Try updating the code for the AndroidAdvertising_APL.xml. It worked for me on version 5.4.2, with both banner and interstitial ads functioning correctly.

image

My AndroidAdvertising_APL.xml :
AndroidAdvertising_APL.xml (13.8 KB)

4 Likes

Hi @Lowenmensch,

I followed your instructions and confirm that it now compiles without errors. Thank you!

I still get a bunch of other errors when I submit it to Google Play Console relating to the SDK being old i.e. 18.1.0, instead of 20.0.0+. Any pointers on how to address that?

Again, thank you very much!

1 Like

I’m glad to hear that it now compiles without errors!

That’s strange about the SDK version errors from Google Play Console because I already updated the dependencies from 18.1.0 to 22.6.0 in the AndroidAdvertising_APL.xml file I shared. Here’s the section for reference:

dependencies {
implementation(‘com.google.android.gms:play-services-ads:22.6.0’)
implementation(‘com.google.android.gms:play-services-ads-lite:22.6.0’)
}

1 Like

Hi @Lowenmensch,

You are right again. At first, I used a file from a local copy of UE5.2 and it didn’t work. I confirm that once I used your file, the errors went away.

Thanks again!

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