adospace / reactorui-maui

MauiReactor is a MVU UI framework built on top of .NET MAUI
MIT License
588 stars 49 forks source link

HotReload Not Work With Android #233

Closed Ali1Jamal closed 5 months ago

Ali1Jamal commented 5 months ago

Hello, i just started new project using MauiReactor template using DotNet 8.0, I use macOS with apple silicon chip and rider ide, after make simple change like change text of lable the hot reload give me this error. in the terminal:

Detected changes to 'Pages/MainPage.cs'
Replacing syntax tree for: Pages/MainPage.cs
Connecting to Hot-Reload server (Port: 45820)...Unable to hot reload the application:
System.Net.Sockets.SocketException (61): Connection refused
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|285_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
   at System.Net.Sockets.TcpClient.CompleteConnectAsync(ValueTask task)
   at MauiReactor.HotReloadConsole.HotReloadClient.SendAssemblyFileToServer(MemoryStream stream, MemoryStream pdbStream, CancellationToken cancellationToken) in D:\a\reactorui-maui\reactorui-maui\src\MauiReactor.HotReloadConsole\HotReloadClient.cs:line 297
   at MauiReactor.HotReloadConsole.HotReloadClient.ConnectionLoop(CancellationToken cancellationToken) in D:\a\reactorui-maui\reactorui-maui\src\MauiReactor.HotReloadConsole\HotReloadClient.cs:line 154

I try to run on real android device and emulator but the hot reload didn't wok with them , I try hot reload with maccatalyst its works but not work with android. my package reference is:

    <ItemGroup>
        <PackageReference Include="Reactor.Maui" Version="2.0.*"/>
        <PackageReference Include="Reactor.Maui.Canvas" Version="2.0.*"/>
        <PackageReference Include="Reactor.Maui.ScaffoldGenerator" Version="2.0.15-beta" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
    </ItemGroup>
adospace commented 5 months ago

Hi, not related to the issue, ScaffoldGenerator is no longer required after beta releases:

    <ItemGroup>
        <PackageReference Include="Reactor.Maui" Version="2.0.*"/>
        <PackageReference Include="Reactor.Maui.Canvas" Version="2.0.*"/>
    </ItemGroup>
adospace commented 5 months ago

regarding your issue with Android, are you sure there is a call to the EnableMauiReactorHotReload() in the program cs?

MauiReactor hot reload uses adb to connect to the emulator/device, can you check if the tool works correctly: https://developer.android.com/tools/adb

Ali1Jamal commented 5 months ago

yes i delete Reactor.Maui.ScaffoldGenerator and then check adb , i didn't set path for adb , after following this blog i was able to fix the problem, also I restart the mac , delete obj and bin for the project, then hot reload work perfectly. thank you for your fast replay.