Is the Unreal Engine 4 Source required to call custom code from C++?

Hello Unreal Developers,
I am currently in the process of porting across a speech recognition plugin.
This port is somewhat working, but I wonder if there is a better way in which it can be called.

I have edited, adding in custom methods to allow me to instantiate and reference my custom code.
Ideally, I would like to have people be able to build and use my plugin with a basic installed version of Unreal Engine 4, rather than downloading the source + editing the source code.
What is the optimal way to go about this? I am sure others must have had this question. I would certainly appreciate any help.

Additionally, if someone can provide an example showing how C++ code can be triggered from Java, that would be great.
At the moment, my solution is a terrible polling system, where I am essentially calling Java methods every 10ms, to see if a word has been spoken.
It’d be preferable to trigger a method from the Java code, when words/phrases were detected.
Granted, i`m sure the overhead for a simple check like that is minimal, in this particular case.


Hey Shane sounds like you want to develop a plugin for UE using the existing hooks for this kind of thing. There is a bunch of documentation and sample plugins you can look to for this. The GearVR plugin which comes with the engine code is a good one. We’re working on a few SDKs which you’re welcome to look at for research including Upsight (GitHub - getsetgames/Upsight: Unreal plugin for integrating the Upsight SDK. Details can be found on their website Take a look at AndroidPluginLanguage.cs and get familiar with APL script. Again the GearVR plugin offers great insight for Android integration… highly recommended.

I’m not sure if it would be the standard way but in your plugin code have a function with a header in the format…

UBT/UAT should pick this up and you can call nativeCPlusPlusCall in your Java code. This worked for me. Do a scan of the engine for “Java_com_epicgames_ue4” you can see some other samples of this naming convention as well.

Also take a look at FAndroidMisc::PlatformInit() in AndroidMisc.cpp for another example of registering native calls.

You should not need to modify any of the engine code to use JNI. AndroidPluginLanguage allows additions of code dynamically to and AndroidJNI.h is a public header as is AndroidApplication.h. As Robert mentioned above writing a plugin is the best way to handle this.

Thanks guys, i`ll take a look at the links you have provided, and can hopefully figure it all out :slight_smile:
This Android port has been too long in the making.
At least the next time I port something to Android, it will hopefully take considerably less time.
Thanks heaps.