Skip to content
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

Mono/C# support on Android #20267

Closed
akien-mga opened this issue Jul 19, 2018 · 13 comments · Fixed by #29359
Closed

Mono/C# support on Android #20267

akien-mga opened this issue Jul 19, 2018 · 13 comments · Fixed by #29359

Comments

@akien-mga
Copy link
Member

We lacked an issue to keep track of Android export support for Mono/C# projects, so here's one.

@neikeq What are the needed steps to get this to work?

@exts
Copy link
Contributor

exts commented Jul 19, 2018

I know @hpvb on discord said he'd be looking into the android stuff. Maybe he can chim in some.

@aaronfranke
Copy link
Member

aaronfranke commented Jul 19, 2018

This applies to iOS too but I'll just post this here for now since we'd likely focus on Android first. The only framework I'm aware of for creating mobile apps using Mono/C# is Xamarin. Unfortunately, these tools are not available for Linux, which is problematic for if we want to make use of them since Godot is a strongly multiplatform game engine. I submitted a feature request here: mono/monodevelop#5228

For Android specifically, I also found this https://github.com/xamarin/xamarin-android

We may be able to use Mono separately from Xamarin on Android and iOS, but it would still be good to have Xamarin working on Linux, to ensure that the underlying tech (Mono) works properly.

@akien-mga
Copy link
Member Author

akien-mga commented Jul 19, 2018

This applies to iOS too but I'll just post this here for now since we'd likely focus on Android first. The only framework I'm aware of for creating mobile apps using Mono/C# is Xamarin.

Well, isn't Godot itself a framework for creating mobile apps using Mono/C# already? We can build Windows apps from Linux with Godot + Mono (i.e. the Linux-compiled C# assemblies work on Windows), so it should work the same for Android, no?

IINM, we just need to find how to include the assemblies in the APK and load them from there - and of course compile the Android export templates with the Mono module, but that shouldn't be hard. (I might miss something specific to non-desktop platforms that would require us to go through a thirdparty framework though).

@dunyakilavuz
Copy link

Since #19839 is closed, forwarding my question.
Is there any rough estimations for android exporting functionality?

@neikeq
Copy link
Contributor

neikeq commented Jul 25, 2018

I will talk about this once 3.1 stable is out.

@DavidJVitale
Copy link

DavidJVitale commented Dec 6, 2018

Although all the official documentation I'm reading on the subject says that Xamarin.Android isn't officially supported on Linux, I've noticed that their repository has instructions for manually building the bindings on Linux, and their CI/CD system even has automatic builds for Ubuntu set up (with the builds occasionally passing). So it looks like it's theoretically possible to hack something together: although I'm not sure that would be a smart long-term solution. Just making sure this information is known.

@migueldeicaza
Copy link
Contributor

We will be happy to make sure that we can produce Xamarin.Android packages from our CI that are suitable for your consumption. We are trying to setup a communications channel between the Godot folks and my team to make sure we are not blocking you.

While you can certainly produce Android packages natively, I would love to see this use Xamarin.Android, mostly because we productize the latter and can provide support to any users that are running into problems. And it would be the same on Windows, Mac and Linux.

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.

@akien-mga
Copy link
Member Author

From what I've heard @neikeq and @hpvb are pretty close to get things running on Android, but there's still some work to do. Probably won't make it in time for 3.1.0, but should hopefully be done shortly after and backported to 3.1.x releases.

@akien-mga akien-mga modified the milestones: 3.1, 3.2 Feb 27, 2019
@nightblade9
Copy link
Contributor

This might be a dumb question, but how exactly is this going to work in terms of exporting? Right now, a "hello world" Godot project for Windows clocks in at around 28MB; I just tried a "hello world" Godot/Mono project, and it clocks in at around 42MB. That's quite large, considering there are no game assets in it yet.

When Android works with C#, is this going to be the same, or is there some sort of DCE/compression/something that will be applied to shrink the APK size down?

@NathanWarden
Copy link
Contributor

I haven't used it in Godot before, but I believe you'll just have to tick the Apk Expansion flag in the export dialog and you'll be able to have an expansion file. Expansion files can be up to 2GB in size. If a person is using C# it might be because they'll be developing a larger game anyway, so a bigger APK file isn't really a big deal.

@NathanWarden
Copy link
Contributor

With that said, I just made an empty Unity build and the APK size was only 16.3 MB and 11 MB with stripping on at the highest setting, so I'm sure there's some sort of stripping and/or compression that can be done :)

@Calinou
Copy link
Member

Calinou commented May 19, 2019

When Android works with C#, is this going to be the same, or is there some sort of DCE/compression/something that will be applied to shrink the APK size down?

APKs are already compressed since they're just ZIP archives (unless you tweak ZIP creation parameters to disable compression, that is). Likewise, desktop games' distributions will likely be compressed somehow (in a ZIP archive or Windows installer, by Steam, …).

@nightblade9
Copy link
Contributor

nightblade9 commented May 20, 2019

@NathanWarden thanks, that's promising. I'm not using C# because I'm making a larger game - I'm using it because I'm much more proficient in it (and I can make much more testable games with it).

Hopefully this will work out well, I'll wait for the appropriate release. I know with .NET Core applications, a "hello world" release app is like 60MB; you can use Mono's dead-code compression thing (the name eludes me just now - the one endorsed by Scott Hanselman) to shrink it to around 40MB. If you zip all the files, it shrinks even further.

Maybe Godot will adopt some of these tools/techniques.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.