radimitrov / CSharpShellApp

83 stars 18 forks source link

Please give a full support for Xamarin Forms/Android #121

Open BanDroid opened 2 years ago

BanDroid commented 2 years ago

I have try to build a native Xamarin Android project, it is compiled perfectly, it just couldn't run the compiled code.

Here's the message i got after successfully compiling:

System.Exception: Error: Specified entry point or Main method not found - 
  at CSharp_Shell.Common.CSharpShellExtensions.InvokeEntryPoint (System.Reflection.Assembly asm, System.String entryPoint, System.String arguments, System.Diagnostics.Stopwatch stopwatch) [0x003fa] in <9d8b6baf7186493493bdfad0361d867b>:0 
  at CSharp_Shell.Activities.MainActivity+<>c__DisplayClass169_0.<Run>b__8 () [0x00026] in <9d8b6baf7186493493bdfad0361d867b>:0 

Screenshot_2022-04-23-13-17-43-531_com.radinc.csharpshell.jpg

BanDroid commented 2 years ago

Here is the project i'm trying to build:

[]()https://drive.google.com/file/d/1z7xeN6f46titRwiwlPhralKAmxD4vPdp/view?usp=drivesdk

radimitrov commented 2 years ago

That is more complicated than you would think. MSBuild won't be available in this app until a stable net6.0-android is released and the app is ported to it. And even then the MSBuild tasks required to build a C# Android application aren't just C#. Take that MainActivity for example. I can think of 5 steps, not necessarily in this order.

  1. The "Activity" attribute, writes to AndroidManifest.xml. Should be doable. Tasks will likely have to be modified.
  2. The task uses bundletool to build an APK with all it's resources. Problematic, I'm not sure it can run on Android at all.
  3. The MainActivity class itself. Android runs Java, not C#. So that class uses Java bindings to communicate between C# and Java.
  4. We also need a Java compiler here to generate the new type properly. This part is a maybe, if JDT is enough.
  5. The task uses R8 to translate Java bytecode into an Android compatible format. This, at least is easy.

So that is a lot of Java and build dependencies. Some of which need to be ported to Android.

BanDroid commented 1 year ago

I Re-open the issue again since i've seen that this app will ported Net 7, so i'm really looking up if there's any plan for this kind of project in the future.

@radimitrov