Where is GameActivity.java stored before setup?


I’m using UE built from sources and need to make changes to GameActivity.java

After engine is set up this file is stored in Engine\Build\Android\Java\src\com\epicgames\ue4\

But it is being overwritten every time engine is installed

So my questions are

  • Where does the engine gets GameActivity file?

  • Where is the best place to do changes to GameActivity.java,
    to put them under source control
    so I can share the code with the team?

Thanks in advance

The template GameActivity.java is in Engine/Build/Android/Java/src/com/epicgames/ue4 but a new version is generated any time you package or launch on. This one ends up in Intermediate/Android/APK/src/com/epicgames/ue4.

The best way to make changes to GameActivity.java is to use UPL (Unreal Plugin Language). There are sections within GameActivity which you may insert code documented in UnrealPluginLanguage.cs. All you need to do is register your UPL XML file in a Build.cs for the Android target. Look at GearVR.Build.cs and GearVR_APL.xml for examples.

Thanks Chris you helped me solve my issue.

Just for anyone looking. GameActivity in ue5 (unreal 5) is in \Engine\Build\Android\Java\src\com\epicgames\unreal
so if you have java code (e.g. android) using the package import you need to change the line
import com.epicgames.ue4.GameActivity;
import com.epicgames.unreal.GameActivity;

Also note that that file has an issue, on line 3369 it references the function OnThermalStatusChangedListener which was added only in api level 29 so you need to target 29 or higher.
Either you would need to patch it (beware it’s a template so it will replace modifications on your project), or target 29+. (setting target-sdk on project settings > android, and ndk api level on project settings > android sdk to 30 worked for me).