Attaching Browser or Mobile application
This page assumes both apps are deployed on the same local network or same machine. For the remote connection, please visit Attaching to the remote tools.
For all platforms, AvaloniaUI.DiagnosticsSupport
package can be installed in the shared project. As well as this.AttachDeveloperTools()
code can be kept in the shared Application
class. If any custom configuration is needed per each platform, OperatingSystem.IsPlatform
APIs can be used.
Attaching Browser application
- Follow Getting Started for the initial setup.
- Run
Developer Tools
application.avdt
dotnet tool can be used from the command line. - Run browser application either via
dotnet run
ordotnet serve
on a published project. Please visit Avalonia WebAssembly documentation for more details. - By default, iOS projects configured to attach to
Developer Tools
on startup. See DeveloperToolsOptions.ConnectOnStartup for details.
To avoid conflicts with Chrome Developer Tools, Avalonia tools shortcut can be redefined from F12
to a custom one. See DeveloperToolsOptions.Gesture for details.
Attaching iOS application
- Follow Getting Started for the initial setup.
- Run
Developer Tools
application.avdt
dotnet tool can be used from the command line. - Run iOS application from your IDE. Please visit Avalonia iOS documentation for more details.
- Make sure browser app is focused, so shortcut can be intercepted. Press
F12
.
Attaching Android application
- Follow Getting Started for the initial setup.
- IMPORTANT: Android doesn't allow any HTTP traffic by default:
- Create
Resources/xml/network_security_config.xml
file:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain> <!-- Debug address -->
</domain-config>
</network-security-config>- In the AndroidManifest.xml file, update
<application>
xml node:
<application android:networkSecurityConfig="@xml/network_security_config">
- For more details, visit https://devblogs.microsoft.com/xamarin/cleartext-http-android-network-security/
SimpleToDoList.Android
project in this repository also contains these changes for reference.
- Create
- Run
Developer Tools
application.avdt
dotnet tool can be used from the command line. - Run Android application from your IDE. Please visit Avalonia Android documentation for more details.
- By default, Android projects configured to attach to
Developer Tools
on startup. See DeveloperToolsOptions.ConnectOnStartup for details.
10.0.2.2
is a default IP address on Android instead of localhost
. It's mapped by the emulator to target host machine. To override it see DeveloperToolsOptions.Protocol.