I wanted to open an issue specific to tracking the status of using Xamarin with Godot. Because I have no idea how to do it, or if it is even possible yet?
I imagine this already works for Windows users, but given that many of us are Linux users; to include many Godot core developers; I wanted to know how we use it too.
Things needed to close this issue:
Applies to Godot current master, and 3.2a2.
Thank you to all of the developers for your time and for making Godot such an awesome engine. I do realize that solving these issues is non-trivial, but if they are solved I wanted to know how? If they are not solved, I would like to know what are the possibilities for ways to solve it, and how can the community help?
See https://github.com/godotengine/godot/issues/20267#issuecomment-461164960 for a response from the founder of Mono and Xamarin.
Any development tools we implement have to be multiplatform, since Godot is multiplatform, and it's Microsoft's business decision to not release Xamarin development tools for Linux. Stated indirectly:
I've been trying to write a reply here which won't get me fired for an hour so far. I don't want to be seen as making company policy, or revealing company secrets.
This is all a discussion of high-level management policy. There's no insurmountable technical barriers to any of the feasible ways to close this issue.
But anyway, thanks for opening this issue, we had nothing to track it before, even if it's looking quite hopeless to do in the near future.
@aaronfranke Thank you for the research, now that I think about it, I remember following you down this same rabbit hole (Only to learn that Evil Empires rarely change their minds about their enemies). Well now I am going to look for a workaround. I tried wine, but failed to get visual studio to install, now trying to get a virtual machine to install everything, but seems godot may not run in a virtual machine. So may be a dead end for Linux Developers?
@FeralBytes I don't understand what you're tying to achieve, Why do you want Xamarin support and why do you need Visual Studio on linux? I've been working with .NET and Godot for a while on linux and I don't have those problems. VSCode works like a charm on Linux for .NET and Godot uses mono for C#.
@ricardoalcantara I want to develop Android apps on Linux using C# which requires Xamarin for Android support.
C#
using Android;
But I can not because Microsoft has purposefully blocked the use of Xamarin on Linux, you have to use it on Windows.
@FeralBytes You don't need Xamarin to make an Android App on Linux with Godot, have you read the documentation? Godot's C# implementation for Android uses Mono. https://github.com/godotengine/godot/pull/29359
@ricardoalcantara How can I use android specific features, for instance I want to turn wifi on and off, not event considering Android 10 which has a special requirement for such operations. Or Say I want to create a service on Android? Or utilize Bluetooth? Can I do these without Xamarin? If we can thoose should be published somewheres for the community to use. It is definitely possible to code around and basicly re-implement Xamarain's features but we really should not have too.
You can do it but you have to do it natively with java, you have to create an android module and setup an interface using Godot APIs and after that you can call it with C#, you can even use android specific dependencies like admob or firebase, actually this is how we do that. http://docs.godotengine.org/en/latest/tutorials/plugins/android/android_plugin.html
[Edit]
An example of plugin I recently saw someone posting o facebook.
https://github.com/mrcrb/godot-plugin-firebase
@ricardoalcantara Yes I know I could write Java, as that is what I did when I wrote the new permissions for Godot, but I want something easier. That required a large amount of setup, and maintanence. C# is integrated, having access to Xamarin would complete the package with out the need of recompiling the entire engine every time.
@FeralBytes They choose not to use Xamarin, there is no Xamarin available to be used.
[Edit]
It's a long time I don't read about Xamarin but AFAIK it's another runtime like Mono, so that's why Microsoft guys wanted to build a binary for Godot, but I read someone (so don't take my word as totally true) that they didn't want to be locked with Xamarin vendors implementation so they decided to go for Mono open source project. Still Microsoft sponsored it. You can read more about it here https://godotengine.org/article/csharp-android-support
Actually Xamarin is still a part of the C# ecosystem. But as stated by the microsoft emplyees, they could get it working for Linux, but they are not going to. So yes there is no Xamarin for Mono, but their is Xamarin for Visual Studio. Not to be confused with Code (Visual Studio Code). You can see the difference between thoose products here.
I know those products, I know Xamarin since before Microsoft purchased it, I know Visual studio since the first one and VSCode too, I know the difference, I know .NET Core (which runs on linux natively), .NET framework and .NET Standards, I know Mono project, I know the moves Microsoft made to make .NET Core, .NET Framework and Mono to have the same code base, I don't have doubts I am trying to solve yours, maybe you don't know Godot enough... and I also know that there is no Xamarin for Godot. What else do you need?
What else do you need?
Xamarin for Godot. Not trying to be rude, but that is the title, technically it isn't, but it is an issue opened for the Godot Engine with a title of Xamarin C# Support. Additionally my first post does ask pretty clearly what I would like.
I don't have doubts I am trying to solve yours,
This is a confusing statement.
maybe you don't know Godot enough...
It seems like you are just trying to insult me now. So I think I will stop having this conversation with you.
Xamarin for Godot
Now I understand, you want to request a feature. This what I asked at the first place. For me your issue is not clear, you opened it as Xamarin was implemented and requesting sample projects. For this issue you better open it here https://github.com/godotengine/godot-proposals
https://github.com/godotengine/godot/issues/33040#issuecomment-546736042
@FeralBytes I don't understand what you're tying to achieve,
It seems like you are just trying to insult me now. So I think I will stop having this conversation with you.
Not at all.
In case there is still any confusion as to why it would be desired to have Xamarin available with Godot, let me just copy paste this bit from Miguel de Icaza's comment:
But most importantly, because then your C# users could call and consume any native APIs from Android without having to use some sort of module, they can access the entire Android API from C# when they so desire.
Edit:
[Edit]
It's a long time I don't read about Xamarin but AFAIK it's another runtime like Mono
Xamarin is built on top of Mono.
For me until C# has Xamarin, this new Java plug-in system is the way forward for me. It makes Java plug-ins much faster to create and modify then ever before.
To work around not having Xarmarin, would it be possible to make a generic Java plugin that does everything that's needed?
I absolutely need to read and write external storage from C# for my project to remake Wolfenstein 3-D for the Oculus Quest. And I really do mean external storage, not the app's private storage and not resources bundled into the APK.
Any development tools we implement have to be multiplatform, since Godot is multiplatform, and it's Microsoft's business decision to not release Xamarin development tools for Linux.
Godot's Android build templates already won't build on Windows, only on Linux. So Godot isn't really multi-platform: it's really Linux-first.
@BenMcLean
To work around not having Xarmarin, would it be possible to make a generic Java plugin that does everything that's needed?
Yes, you can do it in Java and interface with Godot using C# or GDScript (there's other ways too).
Godot's Android build templates already won't build on Windows, only on Linux. So Godot isn't really multi-platform: it's really Linux-first.
I achieve to build Android template on windows and Linux. It just not straightforward, but obliviously it's easier on Linux, windows has many issues that you have to workaround =/. But I agree it's Linux first, because they use Linux and they love FOSS, but the community maintain the other OS compatible as well. Even the Vulkan branch that's been developed on Linux Ubuntu, has other contributors committing to adjust for Windows and MacOS.
Anyway tell us more about your issue building on windows and if it is a bug you can even open an issue for that, providing more information about Version, OS, Logs and soon on. Saying it doesn't build isn't very helpful.
Anyway tell us more about your issue building on windows and if it is a bug you can even open an issue for that, providing more information about Version, OS, Logs and soon on. Saying it doesn't build isn't very helpful.
Oh, I'm sorry, I forgot to mention that the problem there is with Mono. AFAIK, Mono doesn't build on Windows, only on Linux. You can build the regular Android build templates without C# support on Windows, but not the Godot Mono Android build templates.
I know C#, Java and a little C++. But I'm completely lost on how to make this Java plugin. I know how to ask for the permission to read external storage I need in a Java Android app, but not how to make it into a plugin for Godot and make that accessible from C#. I'm not sure how to even start researching that.
Isn't being able to make calls to the Android API inherently part of what "Android support" means? I mean Godot couldn't even run on Android without being able to make Android API calls. However it is doing that should be exposed by default. I'm really confused as to why this would need a plugin when all the plugin's going to do is expose the API that should already be exposed.
@BenMcLean because in short Godot is really a Native C & C++ application, it has just enough Java integrated into it, to talk to Android for only exactly what it needs, this is done as a API between the Native C++ Godot Engine and a Java Program that supports that API, carrying out the required functions for the Engine. The same thing would have to be created in C# for Android... but my argument is that it already exists, it is called Xamarin and to use that in C# you just call using Android but that is not supported for Godot or Linux thanks to Microsoft blocking. We could re-implement the solution in C# and that may be the way forward since Microsoft refuses to lift the ban. But I don't have time for that so I will just use Java as a stop gap.
After reading this, it looks like I would need some major hand-holding from someone who's done it before to make and debug any Godot Java plugin if it was ever going to happen, and I don't think anyone's going to want to take the time for that. Let me know if anyone's interested to help me out.
I think that, if I'm on my own, then I can get my app running in Unity faster than I could figure this out.
If anyone else comes along and wants to know how to get access to external files on Android, here's how it's done on the Java side.
I can't say for certain what will be of this, but just a clarification: The reason this is not done right now is not because of any block by Microsoft. Xamarin Android, albeit not officially supported, can be made to work on Linux and, as Miguel commented, they can produce packages for Godot to use.
I'm not experienced with Xamarin Android, but I would be happy to make this happen. The reason it hasn't happened yet is simply because I have several higher priority tasks.
If anyone with enough knowledge of Godot and Xamarin Android wants to move this forward, I would recommend opening a GIP with detailed information. That would certainly help because, as I said, I'm not experienced with it.
All I actually needed for my project was to request external file permissions so that the popup for it would appear, and "SomeBody3D" on Discord pointed out that this got merged 20 days ago. That exposes what I needed!
Having Xamarin would be nice for other people trying to achieve other things, but to be able to access external file storage, you just need to:
Mark READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE in the Godot export options so that it will be in the manifest and...
Run the Godot.OS.RequestPermisisons() method to get the user's permission before actually accessing the external file storage.
I still need to figure out how to query that the permission was granted so that my program won't try to dig into the files too early, before it actually has permission, (because program execution does not halt to wait for the permission) but this is definitely progress and shows I probably won't need to make a Java plugin for this after all.
Trying to make a plugin just for that would have been crazy!
Recently I could build a Xamarin.Android application in my Linux machine, as described is this issue.
@knuxbbs I will have to try this out soon. Thanks!
Most helpful comment
I'm not experienced with Xamarin Android, but I would be happy to make this happen. The reason it hasn't happened yet is simply because I have several higher priority tasks.
If anyone with enough knowledge of Godot and Xamarin Android wants to move this forward, I would recommend opening a GIP with detailed information. That would certainly help because, as I said, I'm not experienced with it.