Incorrect IP Address using get getLocalHostAddr returns in android in ue4.21.2

I am using

	bool bCanBindAll = false;
	TSharedRef<FInternetAddr> LocalIp = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->GetLocalHostAddr(*GLog, bCanBindAll);
	if (LocalIp->IsValid())
		return LocalIp->ToString(false);
	return FString("");

this code to get ip address in my android application but it always returns , my ip address is not
please help

I have the same problem.

Been having some trouble with this too, thankfully I managed to find a fix (it does require you build the engine from source).

If you look at the GetLocalHostAddr function located in ‘Engine\Source\Runtime\Sockets\Private\Android\SocketSubsystemAndroid.cpp’ you’ll see the following code:

	if (Addr->GetProtocolType() == FNetworkProtocolTypes::IPv4 && Addr->GetRawIp()[0] == 127)
		return Addr;

This appears to be the reason that is getting returned. By looking at the rest of the function you can see that it actually works out what the IP of the device should be. I just removed the above lines and it now works as expected.

I’m sure there must be a reason that it is implemented this way but I can’t quite figure that one out!

I am having trouble getting this static function call to work. When I build I get

error LNK2019: unresolved external symbol “__declspec(dllimport) public: static class ISocketSubsystem * __cdecl ISocketSubsystem::Get(class FName const &)” (_imp?Get@ISocketSubsystem@@SAPEAV1@AEBVFName@@@Z) referenced in function “public: void __cdecl UNetworkingHelper::ShowInfo(void)” (?ShowInfo@UNetworkingHelper@@QEAAXXZ)

even though I
#include “SocketSubsystem.h”