Coder Social home page Coder Social logo

avaloniamauihybrid's People

Contributors

castellobrancotecnologia avatar emmauss avatar jsuarezruiz avatar maxkatz6 avatar mikecodesdotnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

avaloniamauihybrid's Issues

stable nuget package

pleass publich a nuget package withou preview or beta.

this block publish avalonia applications with maui hybrid to google play store and apple store.

erros when compiling a blank solution Avalonia 11.06 with avalonia.maui and net8.0 and communitytoolkit.mvvm 8.2.2

steps to reproduce

  1. Create a balnk solution with avalonia 11.06, select android, ios and mvvm

  2. update packeges

  3. 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

Windows support

Hi, this is awesome, thanks for sharing! Is it possible to add Windows support to the sample too?

Error when using MAUI 8.0.6

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):

  • when updating MAUI to 8.0.6 (currently the latest public version), I need to explicitly add the package Microsoft.Maui.Controls.Compatibility to the target projects (Android, iOS)
  • otherwise the application compiles, but when running, I get a FileNotFoundException of the file Microsoft.Maui.Controls.Compatibility.dll.

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.

Creating MAUI Handler from Avalonia and replacing maui native handlers

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 ?

@jsuarezruiz

Using bindings for MAUI controls causes view to not be rendered at all

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.

1st attempt - keep everything in Maui

This worked on my android emulator (API 30)
but on my physical device (Huawei p30 pro) the UI remains empty

2nd attempt - use avalonia, and only wrap the barcodescanner in host

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
image

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
image

But is actually rendered on top/covering everything else on the emulator:
image

It works though on my device... :-|

Maui embedding to Avalonia is not working with iOS

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.

Embedding AvaloniaView in a Maui Control from an AvaloniaApp

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?

"Inverse" Avalonia Hybrid

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:

  1. 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 ;)

  2. 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?

Cannot run AvaloniaSample.Android

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

Question about native behavior on iOS

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:

  1. The main layout seems to be off
  2. The Avalonia radio buttons don't seem to be responsive
  3. There seems to be a default native style applied (the little (i) icon)

Screenshot 2023-05-05 at 2 53 49 AM
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?
Screenshot 2023-05-05 at 2 53 53 AM

I don't fully understand how MAUI ViewHandlers work, so I could be missing something obvious.

Using MAUI control causes build error: Error AVLN:0004 Avalonia: Unable to resolve suitable regular or attached property Name on type ZXing.Net.MAUI.Controls

I am creating a POC and tried to:

  • use ZXIng.NET.MAUI as barcode reader on Android and IOS
  • and try to implement it somehow differently on Windows.

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

Just try to compile, and you will get:
image

macOS support

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.

mauihybrid solution with all plataforms even without maui

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.