-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Support exporting for Android #73257
Conversation
344e348
to
7609e62
Compare
Does this already work? I'm looking to test C# on Android ASAP :O If so, are there any guides on how to compile everything? |
Yes, this does already work in its current state.
Compiling the editor with mono (note that all the bits that talk about mono itself are outdated and no longer relevant) and compiling the android template, but add the |
Great job. Thank you. |
This pull request is targeting a future 4.x release, as 4.0 is currently in release candidate stage. |
7609e62
to
4347771
Compare
From what I understand, this looks somewhat similar to how it works in 3.x (although much simpler ofc), where we don't target the android specific target framework, right? What .NET runtime is it using, is it Mono? I don't think this is the right way to go. My plan for Godot 4 was to not do anything too custom that's not well-supported by .NET. I'm not convinced the supported-os page is referring to this when they claim Android support. I don't really know for sure, but I think I'm currently waiting to see what's coming in .NET 8, as I think they are working on support for exporting a |
Does it use the CoreCLR runtime? If so, does that still happen when you pass |
This currently works by simply specifying the As far as I can tell, these exports use coreclr as the runtime and mono as the jit. I'll have to test the rest for a bit. |
Before I forget to comment again:
|
In other words, does the multi-platform export template of C# have to wait until after net8? |
While the solution we're going to go with is a different one, currently it still relies on some workarounds this PR implements (copying and extracting the assemblies). So if you can fix the conflicts, I think it's fine to merge this first, then I add the other bits. |
4347771
to
f759cc0
Compare
I rebased #76305 (which contains the interesting bits with the assemblies handling) and then rebased this PR onto that, tho there isn't really much left. Didn't test this as probably everything you want to merge is in the other PR. |
Does this still hold true? |
Please read the above link |
I have, hence my question. |
@XorZy I compiled it in the last week or two and things seem to be working fine. I also updated my csproj to .NET 7 instead of 6. Not sure if that was required or not. |
Thanks for letting me know! EDIT So I tried again, cloning the repo from scratch and checking out the branch "net-android-support". |
Net8 will have nativeAOT support for Linux bionic both x64 and arm64 variants. Full support for shared libraries has only been available in the dotnet runtime repo for about 2 months, so I'm surprised how far you've gotten on net7. Are you publishing as a self contained app, or shared library? |
Since we're not yet in feature freeze for 4.2, I'm merging this now so more people can start testing, and since I need it for my PR as well. |
I downloaded godot 4.2 dev3 and I'm trying to export to android, but it says that in version 4 the export is not yet available, although the release says that you can already test the export (C#: Add initial support for exporting to Android (GH-73257) |
There's already a PR (#80521) fixing that issue, hopefully it will be merged soon. |
@Zamir7 See the "Limitations" paragraph in the first post. .NET 7.0 doesn't properly support arm32 currently. |
|
On .Net 7, the export is successful, but the application does not function, although it starts, practically nothing works, no matter what you click on the screen, nothing changes, as if the ui buttons do not work, and not only ui. |
One of the biggest challenge for me using C# with Godot now for Android deployments is that you can't make use any .Net socket function which requires SSL/TLS. The app crashes immediately. It's working fine on Windows though. It means you can't use HttpClient for https, SSLStream or Grpc over https. There is an open issue about this here and some people are recommending adding libssl.so manually to the APK. I think this is a major issue which should be fixed before the release as most multiplayer games using C# would be needed a TLS connection. Thank you for all your efforts ahead. |
I looked into debugging C# in the android export once relatively long time ago. godotengine/godot-proposals#3689 |
@van800 Sorry, it's easy to miss comments on closed issues/PRs. I'd love to know more about what issues you have with debugging Android C# applications. I'm assuming you are asking to support debugging in JetBrains Rider, Godot uses the Feel free to reach out in the development chat if you have follow-up questions. |
Hi Raul. APK's does not contain libssl dependencies which are required by .Net and any SSL/TLS connection attempt with .Net libraries makes the game crash. The issue explained here #84559, some MS staff even suggested solutions for it and I believe it's a very important bug for .Net developers. |
@ozanyasindogan If there's already an open issue, there's no need to bring it up in other issues/PRs. Let's keep the conversation in that issue #84559 so it can be followed by all the interested parties. |
Limitations: While https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md and https://github.com/dotnet/core/blob/main/release-notes/7.0/supported-os.md claim support for android on x64, arm32 and arm64 for both net6 and net7, actually trying to publish a project for android with the target framework net6 always fails with an error about the native runtime package being missing, same for arm32 on net7. So only x64 and arm64 with target framework net7 can actually be exported.
Because android is particular about what you can put into shared objects, put the published files with the regular assets instead and then copy they on startup into some temporary location so that they can be loaded normally.
Screenshots of a test app running on emulator and an actual tablet:
TODOs:
The assets can sometimes (always?) be accessed by some path directly, so don't copy anything if this is possible.This doesn't really make sense / work. I still left one try with
globalize_path
as the cost is pretty negligible, but could save a lot of time for the first startup