avaloniaui / avaloniamauihybrid Goto Github PK
View Code? Open in Web Editor NEWBrings templated controls, pixel perfect rendering, animations, styling and composition to Maui
License: MIT License
Brings templated controls, pixel perfect rendering, animations, styling and composition to Maui
License: MIT License
When I clone the repo, open solution in latest VS Community (17.7.4) and select AvaloniaSample.Android as startup project, it does not show the Android Emulator next to the run button. When I switch startup project to MauiSample it appears.
I do not have issues with running Maui Apps or even the avalonia.xplat template.
Any ideas?
Edit: It seems that for whatever reason <UseMaui>true</UseMaui>
seems to be the culprit. If I add this to a new avalonia.xplat app created from template I have the same behavior that I can no longer see the Android Targets in Visual Studio and thus cannot deploy it
Are there any plans for an inverse integration, i.e. using Maui "components" in Avalonia?
I'm not talking about the views/controls (although that might be desirable for some people as well, like NativeHost for native controls).
From my point of view, there are especially two fields where Avalonia UI would benefit from MAUI:
Use IDrawable from MAUI
Microsoft.Maui.Graphics (https://learn.microsoft.com/en-us/dotnet/maui/user-interface/graphics/) provides a 2D graphics abstraction (ICanvas
). Since it already has a Skia backend, it should be fairly simple to provide an Avalonia control (counterpart to GraphicsView
in MAUI, see https://learn.microsoft.com/de-de/dotnet/maui/user-interface/controls/graphicsview) which enables drawing an MAUI IDrawable
. I know that Avalonia has its own drawing API (DrawingContext
), but the ability to reuse drawing code from .NET MAUI would be quite welcome ;)
Use platform-specific APIs (Essentials) from MAUI
What is the solution for accessing platform-specific functionality (e.g. GPS, Vibration, Clipboard, etc.) in Avalonia UI?
In .NET MAUI there are platform integration APIs (https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/). Can we use those directly for Avalonia as well. Is there any builder support (host-builder pattern) that integrates MAUI platform APIs with Avalonia?
Or is there any Avalonia-specific alternative available?
steps to reproduce
Create a balnk solution with avalonia 11.06, select android, ios and mvvm
update packeges
make steps of avalunia.maui
a) reference package avalunia.maui
b) update both MainActivity (Android project) and AppDelegate (iOS project) app builders to include .UseMaui()
c) adjust projects :
< UseMau i> true < /UseMaui >
< UseMauiEssentials > true < /UseMauiEssentials >
< SkipValidateMauiImplicitPackageReferences > true < /SkipValidateMauiImplicitPackageReferences >
d) add package reference to projects
< PackageReference Include="Microsoft.Maui.Controls" Version="8.0.3" / >
build solution
the errors are:
Gravidade Código Descrição Projeto Arquivo Linha Estado de Supressão Detalhes
Erro JAVA0000 Error in C:\Users\cesar.nuget\packages\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class:
Type androidx.collection.ArrayMapKt is defined multiple times: C:\Users\cesar.nuget\packages\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class, C:\Users\cesar.nuget\packages\xamarin.androidx.collection.ktx\1.2.0.9\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-ktx.jar:androidx/collection/ArrayMapKt.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\cesar.nuget\packages\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-jvm.jar
androidx/collection/ArrayMapKt.class
at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:126)
at com.android.tools.r8.D8.main(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:5)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\cesar.nuget\packages\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class
at Version.fakeStackEntry(Version_8.1.56.java:0)
at com.android.tools.r8.M.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:5)
at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:81)
at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:32)
at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:31)
at com.android.tools.r8.utils.R0.b(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:2)
at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:26)
at com.android.tools.r8.D8.b(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:13)
at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:24)
at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:113)
... 1 more
Caused by: com.android.tools.r8.utils.b: Type androidx.collection.ArrayMapKt is defined multiple times: C:\Users\cesar.nuget\packages\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class, C:\Users\cesar.nuget\packages\xamarin.androidx.collection.ktx\1.2.0.9\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-ktx.jar:androidx/collection/ArrayMapKt.class
at com.android.tools.r8.utils.O2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:21)
at com.android.tools.r8.utils.O2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:26)
at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:44)
at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:10)
at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2056)
at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:6)
at com.android.tools.r8.graph.b4$a.e(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:7)
at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:58)
at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:9)
at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:8)
at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:29)
at com.android.tools.r8.D8.d(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:17)
at com.android.tools.r8.D8.c(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:1)
at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:28)
... 6 more
SecoviRioApp.Android 1
Aviso CS8032 Uma instância do analisador de CommunityToolkit.Mvvm.SourceGenerators.AsyncVoidReturningRelayCommandMethodAnalyzer não pode ser criada de C:\Users\cesar.nuget\packages\communitytoolkit.mvvm\8.2.2\analyzers\dotnet\roslyn4.3\cs\CommunityToolkit.Mvvm.SourceGenerators.dll : Não foi possível carregar o tipo CommunityToolkit.Mvvm.SourceGenerators.AsyncVoidReturningRelayCommandMethodAnalyzer do assembly CommunityToolkit.Mvvm.SourceGenerators, Version=8.2.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2.. SecoviRioApp C:\Users\cesar.nuget\packages\communitytoolkit.mvvm\8.2.2\analyzers\dotnet\roslyn4.3\cs\CommunityToolkit.Mvvm.SourceGenerators.dll 1 Ativo
Aviso CS8032 Uma instância do analisador de CommunityToolkit.Mvvm.SourceGenerators.AsyncVoidReturningRelayCommandMethodAnalyzer não pode ser criada de C:\Users\cesar.nuget\packages\communitytoolkit.mvvm\8.2.2\analyzers\dotnet\roslyn4.3\cs\CommunityToolkit.Mvvm.SourceGenerators.dll : Não foi possível carregar o tipo CommunityToolkit.Mvvm.SourceGenerators.AsyncVoidReturningRelayCommandMethodAnalyzer do assembly CommunityToolkit.Mvvm.SourceGenerators, Version=8.2.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2.. SecoviRioApp.Android C:\Users\cesar.nuget\packages\communitytoolkit.mvvm\8.2.2\analyzers\dotnet\roslyn4.3\cs\CommunityToolkit.Mvvm.SourceGenerators.dll 1 Ativo
Aviso CS8032 Uma instância do analisador de CommunityToolkit.Mvvm.SourceGenerators.AsyncVoidReturningRelayCommandMethodAnalyzer não pode ser criada de C:\Users\cesar.nuget\packages\communitytoolkit.mvvm\8.2.2\analyzers\dotnet\roslyn4.3\cs\CommunityToolkit.Mvvm.SourceGenerators.dll : Não foi possível carregar o tipo CommunityToolkit.Mvvm.SourceGenerators.AsyncVoidReturningRelayCommandMethodAnalyzer do assembly CommunityToolkit.Mvvm.SourceGenerators, Version=8.2.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2.. SecoviRioApp.iOS C:\Users\cesar.nuget\packages\communitytoolkit.mvvm\8.2.2\analyzers\dotnet\roslyn4.3\cs\CommunityToolkit.Mvvm.SourceGenerators.dll 1 Ativo
Aviso CS8032 Uma instância do analisador de CommunityToolkit.Mvvm.SourceGenerators.AutoPropertyWithFieldTargetedObservablePropertyAttributeAnalyzer não pode ser criada de C:\Users\cesar.nuget\packages\communitytoolkit.mvvm\8.2.2\analyzers\dotnet\roslyn4.3\cs\CommunityToolkit.Mvvm.SourceGenerators.dll : Não foi possível carregar o tipo CommunityToolkit.Mvvm.SourceGenerators.AutoPropertyWithFieldTargetedObservablePropertyAttributeAnalyzer do assembly CommunityToolkit.Mvvm.SourceGenerators, Version=8.2.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2.. SecoviRioApp C:\Users\cesar.nuget\packages\communitytoolkit.mvvm\8.2.2\analyzers\dotnet\roslyn4.3\cs\CommunityToolkit.Mvvm.SourceGenerators.dll 1 Ativo
Aviso CS8032 Uma instância do analisador de CommunityToolkit.Mvvm.SourceGenerators.AutoPropertyWithFieldTargetedObservablePropertyAttributeAnalyzer não pode ser criada de C:\Users\cesar.nuget\packages\communitytoolkit.mvvm\8.2.2\analyzers\dotnet\roslyn4.3\cs\CommunityToolkit.Mvvm.SourceGenerators.dll : Não foi possível carregar o tipo CommunityToolkit.Mvvm.SourceGenerators.AutoPropertyWithFieldTargetedObservablePropertyAttributeAnalyzer do assembly CommunityToolkit.Mvvm.SourceGenerators, Version=8.2.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2.. SecoviRioApp.Android C:\Users\cesar.nuget\packages\communitytoolkit.mvvm\8.2.2\analyzers\dotnet\roslyn4.3\cs\CommunityToolkit.Mvvm.SourceGenerators.dll 1 Ativo
Aviso CS8032 Uma instância do analisador de CommunityToolkit.Mvvm.SourceGenerators.AutoPropertyWithFieldTargetedObservablePropertyAttributeAnalyzer não pode ser criada de C:\Users\cesar.nuget\packages\communitytoolkit.mvvm\8.2.2\analyzers\dotnet\roslyn4.3\cs\CommunityToolkit.Mvvm.SourceGenerators.dll : Não foi possível carregar o tipo CommunityToolkit.Mvvm.SourceGenerators.AutoPropertyWithFieldTargetedObservablePropertyAttributeAnalyzer do assembly CommunityToolkit.Mvvm.SourceGenerators, Version=8.2.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2.. SecoviRioApp.iOS C:\Users\cesar.nuget\packages\communitytoolkit.mvvm\8.2.2\analyzers\dotnet\roslyn4.3\cs\CommunityToolkit.Mvvm.SourceGenerators.dll 1 Ativo
Is it possible to create handlers for maui Controls using Avalonia controls instead of native handlers?
If that is possible then wouldn't it be like all the work is already done for maui to have a drawn backend ?
All we need to do would be to create mappers that maps the Maui IView's property to Avalonia UI controls right ?
Avalonia uses full macOS SDK to run its applications.
While MAUI is based on MacCatalyst.
I am not sure how realistic is to have two-way embedding implemented with these differences. But probably at least one-way embedding is possible.
I have already described my issues with Avalonia.Maui when using .NET 8 and Avalonia 11.0.6 in this issue: #14 (comment)
Related to this issue, I have a second problem (that I track in a different issue to facilitate tracking):
It would be good if Avalonia.Maui could use the version of the NuGet package of the same version of the MAUI I am using.
pleass publich a nuget package withou preview or beta.
this block publish avalonia applications with maui hybrid to google play store and apple store.
Hello... me again.
I am really sorry for bothering you guys, but I keep bumping into stuff.
I am currently trying to "copy" the implementation of the sample of ZXing Maui Barcode Reader
This is the view I try to move to Avalonia:
https://github.com/Redth/ZXing.Net.Maui/blob/main/BigIslandBarcode/MainPage.xaml
I managed to get it to work and actually get rendered.
This worked on my android emulator (API 30)
but on my physical device (Huawei p30 pro) the UI remains empty
Now, it renders the barcode scanner view,
but as soon as I add any binding to those controls (even for bool values), the UI is not rendered anymore - the screen stays brown which is the background color of the Avalonia MainView
Am I missing something here?
Additionally, the rendering seems to not work correctly either:
The camera view should be shown inside the empty space here
But is actually rendered on top/covering everything else on the emulator:
It works though on my device... :-|
blocked at code: await Permissions.RequestAsync();
this line code should show a permission confirm dialog, but now it just block and dot not show any dialog or error. Here is the demo project:
AvaloniaSample.zip
I am creating a POC and tried to:
However, I cannot even get it to compile - once I add the MAUI control, I get a build error.
Note: This does nothappen, if I use a built-in MAUI control such as "<mauiControls:Button />"
Am I doing anything wrong here?
Repro is available here: https://github.com/gentledepp/POC_AvaloniaMauiApp01/tree/repro/mauicontrol
Hi, this is awesome, thanks for sharing! Is it possible to add Windows support to the sample too?
As I understand it, this is an experiment, so this is not really an issue.
It's a question for my own understanding -- why is it that when I run this on my local emulator (M1 MacBook, iPhone14 iOS 16.4), there are a few issues:
The only way I've found so far to remove the unwanted icon is to add a line to Avalonia.MAUI.Platforms.iOS.AvaloniaViewHandler.ConnectHandler
platformView.TintColor = UIColor.Clear;
But when I run it on Android, all seems well?
I don't fully understand how MAUI ViewHandler
s work, so I could be missing something obvious.
I'm trying to create an IME (keyboard) View in Android within an Avalonia app. The goal was to use an Avalonia.Android.AvaloniaView
as a wrapper to host Avalonia controls to show the keyboard but it appears that there's airspace issues, no matter what I do the keyboard is always full screen (always overlaying a white unchangeable background).
Testing from a Maui-based app works great, no airspace problem and embedding my keyboard in a Avalonia.Maui.Controls.AvaloniaView
works as expected BUT my actual app is not a MAUI app...
Back in the Avalonia App, what I tried to do was a double embed kind of thing like this:
var mauiView = new ContentView
{
Content = new Avalonia.Maui.Controls.AvaloniaView()
{
Content = new MyKeyboardView()
}
};
Which is fine until calling mauiView.ToPlatform
to get the native Android View
. It causes the app/UI to freeze. This is how I'm converting it:
View androidView = mauiView.ToPlatform(MainActivity.Instance.GetWindow().Handler.MauiContext);
I tried messing with AppBuilder
configurations but had no luck and it only freezes after setting the ContentView.Content
to the AvaloniaView
. Is there any way to get this to work from an Avalonia app?
Hi,
i'm going to the readme: https://github.com/AvaloniaUI/AvaloniaMauiHybrid#embedding-maui-controls-inside-of-the-avalonia-app
but when i start the android app i get an exception:
Java.Lang.IllegalArgumentException: 'The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).'
If i comment out the maui button the project works:
<mauiControls:Button Text="Maui Button" />
I use the following versions:
.NET 8
Avalonia.iOS: 11.0.9
Avalonia.Maui: 11.0.9
Microsoft.Maui.Controls: 8.0.7
Microsoft.Maui.Essentials: 8.0.7
Steps to reproduce:
Follow the guide in the README.md
When you reach the point when you need to use the UseMaui() extension method you can see, that not selecting the required extension method for iOS which requires the AppDelegate instance, instead it uses the simple UseMaui method with the AppBuilder.
Could someone please post the instructions so that a solution with Avalonia Maui Hybrid has Windows and browser projects without Maui Hybrid (use Maui would have to be conditional in the main project, for example) etc etc.
This would allow where Maui is not supported the programmer to create their own solutions.
Thank you very much in advance
Hi,
When trying out the AvaloniaSample.iOS sample project (Visual Studio 17.10.3 for Windows, Phone SE 3rd gen tethered for "Hot Reload"):
No class inheriting from a valid Application Delegate found in /var/mobile/Containers/Data/Application/457228A1-2559-44E4-810B-4C91859D26BE/Documents/AvaloniaSample.iOS.content/AvaloniaSample.iOS.dll
.If I try the MauiSample project, it works - this only occurs with the AvaloniaSample.
What could be wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.