The app is crashing when receiving a network message. This problem goes away if the server and network are running on separate apps.
Here is a simple example that will reproduce the error. It will run without error on windows but crashes on Android Google Play Template.
Using NDK r16b and android studio version 3.1.1
// Includes
#include "template.h"
// Namespace
using namespace AGK;
float iTimer = 0;
int iServerNetwork = 0;
int iClientNetwork = 0;
int iLastMessage = 0;
int iCount = 0;
app App;
void app::Begin(void)
{
agk::SetVirtualResolution (1024, 768);
agk::SetClearColor( 151,170,204 ); // light blue
agk::SetSyncRate(60,0);
agk::SetScissor(0,0,0,0);
iTimer = agk::Timer() + 3;
}
int app::Loop (void)
{
if (agk::Timer() > iTimer)
{
iTimer = agk::Timer() + 2;
iCount++;
if (iCount == 1)
{
iServerNetwork = agk::HostNetwork("TestServer", "TestWorld", 1050);
} // Start The Server
else if (iCount == 2)
{
iClientNetwork = agk::JoinNetwork("127.0.0.1", 1050, "TestClient");
} // Start The Client
else
{
int iMessage = agk::CreateNetworkMessage();
agk::AddNetworkMessageInteger(iMessage, iCount);
agk::SendNetworkMessage(iServerNetwork, 0, iMessage);
} // Send a Message From Server To Client
}
// Check Client And Get Messages Received From Server
int iNewMessage = agk::GetNetworkMessage(iClientNetwork);
if (iNewMessage > 0)
{
iLastMessage = agk::GetNetworkMessageInteger(iNewMessage);
agk::DeleteNetworkMessage(iNewMessage);
}
agk::Print(agk::Timer());
agk::Print(iServerNetwork);
agk::Print(iClientNetwork);
agk::Print(iLastMessage);
agk::Sync();
return 0;
}
void app::End (void)
{
}