lidgren / lidgren-network-gen3

Lidgren Network Library
https://groups.google.com/forum/#!forum/lidgren-network-gen3
MIT License
1.19k stars 331 forks source link

Trying to compile for Android #138

Open joaoroque opened 4 years ago

joaoroque commented 4 years ago

Hi,

I have an old project I developed with lidgren when I feel there was a bit more documentation than now. But now 5 years later I can't remember most things.

I'm doing a xamarin android app that uses lidgren. So I added the Lidgren.Network project to my solution and added the "ANDROID" compilation symbol to the build options of lidgren project.

Now when trying to compile I get the exception: "The name Android does not exist in the current context" on a bunch of lines. For example in:

Android.Util.Log.WriteLine(Android.Util.LogPriority.Verbose, "", message);

The project doesn't even compile because of that.

Anyone knows what I'm doing wrong?

Thanks,

João

joaoroque commented 4 years ago

After some trial and error I figured it out. I'll leave here the steps to get lidgren working on Xamarin Android.

xafgun commented 4 years ago

After some trial and error I figured it out. I'll leave here the steps to get lidgren working on Xamarin Android.

  • The current version is bugged on android. It uses a mutex which is not supported by mono from what I've read. So, download the zip from this commit: https://github.com/lidgren/lidgren-network-gen3/tree/e26203f6526835779dcf7d2357e4ebab642e72e6 It is the most recent commit before they introduce the change that breaks on Android.
  • Add the Lidgren.Network project from the zip you downloaded to your solution that contains the Android project.
  • Add Mono.Android refrence to Lidgren.Network project. You can check the folder path on your Android project as it is already being used there.
  • Add Lidgren.Network as a project reference to your Android project.
  • Go to Lidgren.Network project properties, then build tab and set the following as the conditional compilation symbol (both for debug and release): __ANDROID__
  • Add INTERNET permission to your app.

Is this version work on IOS 13.3.1 ?