erros when compiling a blank solution Avalonia 11.06 with avalonia.maui and net8.0 and communitytoolkit.mvvm 8.2.2
CastelloBrancoTecnologia opened this issue · 6 comments
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.mauib) 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
After updating Avalonia packages to latest pre release build packages 11.99999 i can compile avalonia hibrid
I succefuly fixed it (android compiling erros with net 8 and avalonia 11.0.7) forking avalonia hybrid, changing project file to only use net8 (removing net7), updating packages refenrence to latest versions and adding these two references
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.3.0.2" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.2" />
the resulting Avalonia.MAUI project file is
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
<UseMaui>true</UseMaui>
<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<PackageReference Include="Avalonia.Android" Version="$(AvaloniaVersion)" />
<!--<PackageReference Include="Xamarin.Kotlin.StdLib.Jdk8" Version="1.9.22" />-->
<PackageReference Include="SkiaSharp.NativeAssets.Android" Version="2.88.7" />
<PackageReference Include="HarfBuzzSharp.NativeAssets.Android" Version="7.3.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.3.0.2" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.2" />
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<PackageReference Include="Avalonia.iOS" Version="$(AvaloniaVersion)" />
<PackageReference Include="SkiaSharp.NativeAssets.iOS" Version="2.88.7" />
<PackageReference Include="HarfBuzzSharp.NativeAssets.iOS" Version="7.3.0.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.7" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.Maui.Controls" Version="8.0.6" />
<PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.6" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
<!-- Packaging -->
<PropertyGroup>
<IsPackable>true</IsPackable>
<Version>11.0.5.2</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/AvaloniaUI/AvaloniaMauiHybrid</RepositoryUrl>
<PackageTags>avalonia;avaloniaui;maui;android</PackageTags>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageIcon>Icon.png</PackageIcon>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageId>CBT.$(AssemblyName)</PackageId>
</PropertyGroup>
<ItemGroup Label="PackageIcon">
<None Include="Icon.png" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>
<!-- /Packaging -->
<Target Name="PushNuGetPackage" AfterTargets="GenerateNuspec">
<Message Text="Push NuGet Package to NuGet Feed" Importance="high"></Message>
<Exec Command="dotnet nuget push "$(ProjectDir)bin\$(Configuration)\CBT.$(AssemblyName).$(Version).nupkg" --source "github""></Exec>
</Target>
</Project>
can somdone see this information and integrete it to next version of avalonia hybrid ?
I have the same issue:
- NET 8
- Avalonia 11.0.8
So at the moment I need to stay on Avalonia 11.0.5
Should work better with 11.0.9 (or 7+) and Avalonia.Maui 11.0.9
For future reference, any AndroidX version conflict issues should be reported to the https://github.com/xamarin/AndroidX repository.