AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.1k stars 2.26k forks source link

xpat template fire exception during run at android #16722

Closed guyulmaz closed 3 months ago

guyulmaz commented 3 months ago

Describe the bug

Hi I try to setup avalonia xplat template at macbook m1 . desktop and browser projects build and run successful. I try to setup android project. it is building successful, during dotnet run it is giving below errors, what can be reason. I has already downloaded android studio and made emulater run, before pressing dotnet run.

I did not changed any code from xpat template

using Android.App; 
using Android.Content.PM; 
using Avalonia; 
using Avalonia.Android; 

namespace MyApp.Android; 

[Activity( 
    Label = "MyApp.Android", 
    Theme = "@style/MyTheme.NoActionBar", 
    Icon = "@drawable/icon", 
    MainLauncher = true, 
    ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)] 
public class MainActivity : AvaloniaMainActivity<App> 
{ 
    protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) 
    { 
        return base.CustomizeAppBuilder(builder) 
            .WithInterFont(); 
    } 
}

To Reproduce

dotnet new avalonia.xplat-o MyApp

cd MyApp.Android

dotnet build -> successful

dotnet run -> below error


... MyApp.Android % dotnet run  
  Determining projects to restore...
  All projects are up-to-date for restore.
  MyApp -> /Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp/bin/Debug/net8.0/MyApp.dll
  MyApp.Android -> /Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/bin/Debug/net8.0-android/MyApp.Android.dll
  MyApp -> /Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp/bin/Debug/net8.0/MyApp.dll
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018: The "FastDeploy" task failed unexpectedly. [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018: System.ArgumentOutOfRangeException: Specified time is not supported in this calendar. It should be between 04/30/1900 00:00:00 (Gregorian date) and 11/16/2077 23:59:59 (Gregorian date), inclusive. (Parameter 'time') [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018: Actual value was 504911232000000000. [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018:    at System.Globalization.UmAlQuraCalendar.CheckTicksRange(Int64 ticks) [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018:    at System.Globalization.UmAlQuraCalendar.GetDatePart(DateTime time, Int32 part) [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018:    at System.DateTimeFormat.FormatCustomized[TChar](DateTime dateTime, ReadOnlySpan`1 format, DateTimeFormatInfo dtfi, TimeSpan offset, ValueListBuilder`1& result) [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018:    at System.DateTimeFormat.TryFormat[TChar](DateTime dateTime, Span`1 destination, Int32& charsWritten, ReadOnlySpan`1 format, IFormatProvider provider, TimeSpan offset) [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018:    at System.DateTime.TryFormat(Span`1 destination, Int32& charsWritten, ReadOnlySpan`1 format, IFormatProvider provider) [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018:    at System.Text.ValueStringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ReadOnlySpan`1 args) [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018:    at System.String.FormatHelper(IFormatProvider provider, String format, ReadOnlySpan`1 args) [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018:    at System.String.Format(String format, Object arg0, Object arg1) [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]

/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018:    at Xamarin.Android.Tasks.FastDeploy.Execute() in /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line 196 [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Execute() [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.Debugging.targets(678,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/Users/guyulmaz/kod/avalonia/template1/MyApp/MyApp.Android/MyApp.Android.csproj]

Build FAILED.

Expected behavior

should run successfully.

Avalonia version

11.1.3

OS

macOS, Android

Additional context

At the xplat template there is no code related to Datetime or Calendar, but this error is coming from deep somewhere underhood.

timunie commented 3 months ago

Please upload a very minimal sample (why? want to check Avalonia version and if there is something that was added unexpectly).

Most of the time if debug works and run not, it could be trimming related

workgroupengineering commented 3 months ago

I think it's not avalonia related. It seems to be an android workload issue that probably doesn't recognize the Saudi Hijri (Um Al Qura) calendar date format. Try setting your system to en-us culture.

maxkatz6 commented 3 months ago

Consider creating this issue at https://github.com/dotnet/android