Hi everybody
I need to call Java code from c++
I try to write my own function in GameActivity.java, do all other stuff from the instruction from here: Platform specific functionality in UE4 game? - Mobile - Epic Developer Community Forums
But I get the undefined reference linker error while calling it in line:
FJavaWrapper::CallVoidMethod(Env, FJavaWrapper::GameActivityThis, FJavaWrapper::AndroidThunkJava_MyFunc,Argument);
This line of code calling functions implemented by engine works well. Everything is implemented just like function AndroidThunkJava_LaunchURL
Looks like the AndroidJNI.h isn’t being loaded after changing, but if I write some syntax error code the compiler sees the errors.
If I do
jmethodID jmID = FJavaWrapper::AndroidThunkJava_MyFunc;
FJavaWrapper::CallVoidMethod(Env, FJavaWrapper::GameActivityThis, jmID, Argument);
I receive error:
MainFrameActions: Packaging (Android (ETC2)): UnrealBuildTool: C:\Program Files\Epic Games\4.8\Engine\Source\Runtime/Core/Public\GenericPlatform/GenericPlatformString.h:146: error: undefined reference to 'FJavaWrapper::AndroidThunkJava_MyFunc'
There’s the function
template <typename SourceEncoding, typename DestEncoding>
static typename TEnableIf<
// This overload should be called when the types are not compatible but the source is fixed-width, e.g. ANSICHAR->WIDECHAR.
!TAreEncodingsCompatible<SourceEncoding, DestEncoding>::Value && TIsFixedWidthEncoding<SourceEncoding>::Value,
DestEncoding*
>::Type Convert(DestEncoding* Dest, int32 DestSize, const SourceEncoding* Src, int32 SrcSize, DestEncoding BogusChar = (DestEncoding)'?')
{
const SourceEncoding* InSrc = Src;
int32 InSrcSize = SrcSize;
bool bInvalidChars = false;
while (SrcSize)
{
if (!DestSize)
return NULL;
SourceEncoding SrcCh = *Src++;
if (CanConvertChar<DestEncoding>(SrcCh))
{
*Dest++ = (DestEncoding)SrcCh;
}
else
{
*Dest++ = BogusChar;
bInvalidChars = true;
}
--SrcSize;
--DestSize;
}
if (bInvalidChars)
{
LogBogusChars<DestEncoding>(InSrc, InSrcSize);
}
return Dest;
}
And error is in line
*Dest++ = (DestEncoding)SrcCh;
What does this mean?