Skip to content

Project migration to new model with Android support#337

Open
Shivansps wants to merge 68 commits intoKnossosNET:mainfrom
Shivansps:project-migration
Open

Project migration to new model with Android support#337
Shivansps wants to merge 68 commits intoKnossosNET:mainfrom
Shivansps:project-migration

Conversation

@Shivansps
Copy link
Copy Markdown
Member

@Shivansps Shivansps commented Oct 1, 2025

The intention of this PR is to upgrade the project/solution to the newer model allowing for both Desktop and Android builds.

And while an android build can now be compiled, it is not completely usable. This is intended to create the base for a future android build while testing everything still works as expected with the desktop versions, not to produce a working android build.

Android specific work can start after this one is merged.

Changes:

With the change to the new model, now to compile a desktop build, the Knossos.NET.Desktop project must be used. The idea is to keep using NET 6 for desktop builds.

The resulting executable file is now called "Knossos.NET.Desktop.exe" i dont really want to use that, so they have to be renamed to "Knossos.NET.exe" changing the assembly name creates lots of problems and even then the compiled still did not changed the name. SO it will be better to either accept the new name or to rename the executable.

The second issue is, as android is single view and can not create windows, i had to take petty much everything away from the main window view and model and move it into "MainView" and "MainViewModel", this could create significant issues so everything that runs on the main view need to be tested again. And thats include custom mode.

All dialogs that created new windows, like MessageBox and everything on Views/Windows with the exception of MainWindow and SapiVoices(Windows specific), were moved to a new type called "KnossosWindow", now these dialogs were changed from Window to KnossosWindow, that extend UserControl, this new system add stuff we used from Window that was missing on UserControl, and on a Desktop OS will create a new Window as normal, but on Android it will display the view in a overlay over the MainView.
No need to say this means all dialogs that created new window could have potential issues, altrought i havent found anything so far.

Auto update need to be tested again with both executable names, ill figure a way to do that.

The integrated github build will need to be adjusted to this model too.

Compiling:

To compile a desktop version as before, you must use the Knossos.NET.Desktop project, to compile the Android version, choose the Knossos.NET.Android (only from cmdline, not from VS)

Build and publish the desktop version for windows x64 in net 6:

dotnet build Knossos.NET.Desktop -c Release -r win-x64 -f net6.0
dotnet publish Knossos.NET.Desktop -c Release -r win-x64 -f net6.0 --self-contained

Build the Android version:

dotnet build Knossos.NET.Android -c Release -f net10.0-Android -p:BuildAndroid=true

That creates a signed apk for all cpu archs ready to install in any device that is android 9+, no need to use publish for this.

Compile and upload to phone directly for development:

dotnet run -c Debug -f net10.0-Android -p:BuildAndroid=true

Run from inside the Knossos.NET.Android folder, not the solution folder as before, phone needs to be on developer mode, with usb debugging enabled and adb daemon needs to be already running on your pc, so make sure to start it manually first.

"-p:BuildAndroid=true" is used to enable the project for android and the net10.0-Android target framework.

When working with android apps i also recommend to use "scrcpy"
https://github.com/Genymobile/scrcpy/releases/tag/v3.3.3

scrcpy will connect to the phone using adb and it will start the daemon too, so you can see and use everything directly on your pc without having to pickup the phone or do anything with it

NOTES:

To compile for android you will need the net 10 sdk installed and then install the android workload with
"dotnet workload install android" on a console.
If you only want to compile for desktop on VS, the android proyect will still be compiled as a dll even after selecting the "Knossos.NET.Desktop" as your starting project and will need the android workload installed, a workaround for this is just to unload the "Knossos.NET.Android" project (right click->unload proyect)

@Shivansps Shivansps changed the title Project migration to new model Project migration to new model with Android support Oct 5, 2025
@Shivansps Shivansps marked this pull request as draft December 5, 2025 22:51
@Shivansps Shivansps added this to the 1.4 milestone Dec 5, 2025
@Shivansps Shivansps added the enhancement New feature or request label Dec 5, 2025
@Shivansps Shivansps changed the title Project migration to new model with Android support Project migration to new model with Android support (will be rebased) Dec 5, 2025
@Shivansps
Copy link
Copy Markdown
Member Author

Shivansps commented Mar 30, 2026

@notimaginative sorry to bother you, but you could check my CI changes of the last 4 commits? i did used claude to do these changes and explain it to me how it worked.

The idea is:

  1. now we compile Knossos.NET.Desktop project for windows/linux/mac, still using .net 6.0
  2. the executable gets renamed (the result is Knossos.NET.Desktop.exe and it does not work to change it in the proyect file) to remove the ".Desktop" from it, in order not to break the auto update.
  3. add the android job, it generates a signed apk using .net 10.

In my tests, it did generated all files with the correct names on a draft release

@notimaginative
Copy link
Copy Markdown
Contributor

I can't tell from a quick look so I'll have to give this a proper test and see how it works. I should be able to do that sometime tomorrow.

@Shivansps
Copy link
Copy Markdown
Member Author

I can't tell from a quick look so I'll have to give this a proper test and see how it works. I should be able to do that sometime tomorrow.

thanks

@notimaginative
Copy link
Copy Markdown
Contributor

I think those CI changes can be simplified quite a bit. Plus it would be nice to use the same setup and scripts for both desktop and android builds. Let me work on it a little and I'll send you a patch tomorrow.

@notimaginative
Copy link
Copy Markdown
Contributor

Couple of questions...

  1. Should the android build be packaged in a zip file or just left as a plain apk?
  2. When running in an emulator I'm getting warnings about the .so's not being 16 KB aligned. Do we need to consider having both 4 KB and 16 KB versions of the apk? If so then does the answer to question 1 change at all (like having Android_4KB-1.3.4.zip / Android_16KB-1.3.4.zip)?

@Shivansps
Copy link
Copy Markdown
Member Author

Couple of questions...

  1. Should the android build be packaged in a zip file or just left as a plain apk?
  2. When running in an emulator I'm getting warnings about the .so's not being 16 KB aligned. Do we need to consider having both 4 KB and 16 KB versions of the apk? If so then does the answer to question 1 change at all (like having Android_4KB-1.3.4.zip / Android_16KB-1.3.4.zip)?
  1. the apk is petty much a zip already. Its better to leave like that.
  2. the 16kb warnings is due to one of the core dependencies lib used by avalonia not shipping with a 16B aligned .so. This is not a problem, 16KB aligned .so can be used on both 4kb and 16kb systems. So once the dependency updates that will go away on its own and there is no need to have two versions.

@notimaginative
Copy link
Copy Markdown
Contributor

Here is the patch of my CI changes against this PR. Along with unifying the setup I also bumped the GitHub action versions to get rid of the node20 deprecation warnings and disabled the net6.0 end-of-life warnings when built via the scripts. Scripts verified to work locally, workflow verified to complete a full set of builds and create a new draft release.

337-ci-cleanup.patch

@Shivansps
Copy link
Copy Markdown
Member Author

@notimaginative everything seems to be working, thanks.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants