My project only needs basic Http Get/Post networking so I’ve been trying to use the Http module. It works fine on windows and mobile preview, but fails on Android. Digging through the source code it appears FAndroidPlatformHttp uses FGenericPlatformHttp, which looks like an abstract class. Debug printouts confirm Request->ProcessRequest immediately returns false. Is there some other way within Unreal to use Http networking on Android or will I have to use a 3rd party library?
We have not implemented HTTP support on Android yet, but UE4 does use libcurl for HTTP on Linux. With some small modifications to the engine, it should be possible to use UE4’s libcurl support on Android as well.
Alright, figured it out, for future reference of anyone else looking to do this:
Modify AndroidHttp source and header to look like the LinuxPlatformHttp source and header, with methods appropriately renamed.
Add the following to libcurl.build.cs:
else if (Target.Platform == UnrealTargetPlatform.Android)
{
switch (Target.Architecture)
{
case "-armv7":
PublicLibraryPaths.Add(LibCurlPath + "lib/Android/ARMv7");
break;
case "-arm64":
PublicLibraryPaths.Add(LibCurlPath + "lib/Android/ARM64");
break;
case "-x86":
PublicLibraryPaths.Add(LibCurlPath + "lib/Android/x86");
break;
case "-x64":
PublicLibraryPaths.Add(LibCurlPath + "lib/Android/x64");
break;
}
PublicIncludePaths.Add(LibCurlPath + "include_android_armv7");
PublicAdditionalLibraries.Add("curl");
PublicAdditionalLibraries.Add("crypto");
PublicAdditionalLibraries.Add("ssl");
PublicAdditionalLibraries.Add("dl");
}
The next part involves obtaining the libcurl and libssl libraries/headers compiled for android, Here is the link to my own build of them and hopefully that will work for you. For reference, it was built using ndk r9d standalone toolchain targeting ARMv7 API level 17. If you need to compile it yourself, the source code is under the linux build directory in the UE4 source. I highly recommend you do not use cygwin to attempt it, if you don’t have linux handy to compile it I recommend setting up virtualbox with an Ubuntu installation.
In the libcurl module directory create a folder named include_android_armv7 and place the headers in that folder under a subfolder named curl: include_android_armv7/curl/*.h Yes the headers are different from the linux build, if you are using something other than armv7 you may have to make additional folders and put the compiled headers in those as well, I’m not sure on that without another tablet to test on though.
Under the lib folder create a folder named Android, and in that folder create the folders for the architechtures (ARMv7, ARM64,X86,X64) Place the compiled static (.a) library files in the appropriate architecture folder (the included ones go in ARMv7)
Rebuild the editor and then use the HTTP module like you normally would.