dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 528 forks source link

Error APT2260 after upgrading to .NET 8 Android #8882

Closed amirvenus closed 6 months ago

amirvenus commented 6 months ago

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

8.0.203

Description

Similar to #8606 , On a project upgraded from Xamarin.Android to either net7.0-android or net8.0-android, there are errors like this:


0>styles.xml(2): Error APT2260 : resource attr/colorOnSecondary (aka Platform.Android:attr/colorOnSecondary) not found.
0>styles.xml(2): Error APT2260 : resource attr/colorSecondary (aka Platform.Android:attr/colorSecondary) not found.
0>styles.xml(2): Error APT2260 : style attribute 'attr/colorOnPrimary (aka Platform.Android:attr/colorOnPrimary)' not found.
0>styles.xml(2): Error APT2260 : resource attr/colorSecondary (aka Platform.Android:attr/colorSecondary) not found.
0>styles.xml(2): Error APT2260 : resource attr/colorOnPrimary (aka Platform.Android:attr/colorOnPrimary) not found.
0>styles.xml(2): Error APT2260 : style attribute 'attr/colorOnSecondary (aka Platform.Android:attr/colorOnSecondary)' not found.
0>styles.xml(2): Error APT2260 : style attribute 'attr/colorSecondary (aka Platform.Android:attr/colorSecondary)' not found.
0>Xamarin.Android.Aapt2.targets(156,3): Error APT2260 : resource style/Widget.MaterialComponents.Button.TextButton.Dialog (aka Platform.Android:style/Widget.MaterialComponents.Button.TextButton.Dialog) not found.
0>Xamarin.Android.Aapt2.targets(156,3): Error APT2260 : resource style/Widget.MaterialComponents.Button.TextButton.Dialog (aka Platform.Android:style/Widget.MaterialComponents.Button.TextButton.Dialog) not found.
0>Xamarin.Android.Aapt2.targets(156,3): Error APT2260 : resource style/Widget.Design.TabLayout (aka Platform.Android:style/Widget.Design.TabLayout) not found.
0>styles.xml(2): Error APT2260 : style attribute 'attr/tabIndicatorColor (aka Platform.Android:attr/tabIndicatorColor)' not found.
0>styles.xml(2): Error APT2260 : style attribute 'attr/tabIndicatorHeight (aka Platform.Android:attr/tabIndicatorHeight)' not found.
0>styles.xml(2): Error APT2260 : style attribute 'attr/tabSelectedTextColor (aka Platform.Android:attr/tabSelectedTextColor)' not found.
0>styles.xml(2): Error APT2260 : style attribute 'attr/tabTextAppearance (aka Platform.Android:attr/tabTextAppearance)' not found.
0>Xamarin.Android.Aapt2.targets(156,3): Error APT2260 : resource style/TextAppearance.Design.Tab (aka Platform.Android:style/TextAppearance.Design.Tab) not found.
0>ThemesBase.xml(2): Error APT2260 : resource attr/colorSurface (aka Platform.Android:attr/colorSurface) not found.

They are indeed already referenced in the csproj:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
    <PropertyGroup>
        <RootNamespace>Platform.Android</RootNamespace>
        <PackageId>Platform.Android</PackageId>
        <AssemblyName>Platform.Android</AssemblyName>
        <!--<EnableDefaultCompileItems>false</EnableDefaultCompileItems>-->
        <DefineConstants>$(DefineConstants);</DefineConstants>
        <LangVersion>latest</LangVersion>
        <GenerateAssemblyInfo>true</GenerateAssemblyInfo>
        <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
        <BuildWithMSBuildOnMono>true</BuildWithMSBuildOnMono>
        <TargetFramework>net8.0-android</TargetFramework> 
        <AndroidLinkMode>None</AndroidLinkMode>
        <AndroidUseManagedDesignTimeResourceGenerator>false</AndroidUseManagedDesignTimeResourceGenerator>
        <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
        <AndroidResgenClass>Resource</AndroidResgenClass>  
        <OutputType>Library</OutputType>
        <ImplicitUsings>enable</ImplicitUsings>
        <SingleProject>true</SingleProject>
        <IsPackable>false</IsPackable>

    </PropertyGroup>  
    <PropertyGroup Condition=" '$(Configuration)'=='Release' ">
        <OutputPath>bin\Release</OutputPath>

    </PropertyGroup>
    <ItemGroup>
        <None Include="app.config"/>
        <AndroidResource Include="Resources/**/*.xml"/>
        <AndroidResource Include="Resources/**/*.axml"/>
        <AndroidResource Include="Resources/**/*.png"/>
        <AndroidResource Include="Resources/values/styles.xml"/>
    </ItemGroup>
    <ItemGroup>
        <PackageReference Include="AndHUD" Version="2.0.1"/>
        <PackageReference Include="Genetics" Version="1.1.0.50"/>
        <!--<PackageReference Include="NETStandard.Library" Version="2.0.3" />-->
        <PackageReference Include="Xam.Plugins.TextToSpeech" Version="4.0.0.7"/>
        <PackageReference Include="Xamarin.Controls.SignaturePad" Version="3.0.0"/>
        <PackageReference Include="ZXing.Net.Mobile" Version="3.1.0-beta2"/>
        <PackageReference Include="ZXing.Net.Bindings.CoreCompat.System.Drawing" Version="0.16.8-beta"/> 
        <PackageReference Include="Xamarin.AndroidX.Annotation" Version="1.6.0.4"/>
        <PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.6.1.3"/>
        <PackageReference Include="Xamarin.AndroidX.GridLayout" Version="1.0.0.14"/>
        <PackageReference Include="Xamarin.AndroidX.Preference" Version="1.2.0.4"/>
        <PackageReference Include="Xamarin.AndroidX.Work.Runtime" Version="2.8.1.3"/>
        <PackageReference Include="Xamarin.Controls.SignaturePad">
            <Version>3.0.0</Version>
        </PackageReference>
        <PackageReference Include="Xamarin.Essentials" Version="1.8.0"/>
    </ItemGroup>
    <ItemGroup>
        <ProjectReference Include="..\Platform.Common\Platform.Common.csproj"/>
    </ItemGroup>
    <ItemGroup>
        <Folder Include="Resources\values-b+de\"/>
    </ItemGroup>
</Project>

Steps to Reproduce

We're unable to reproduce with a new project, yet.

Did you find any workaround?

No response

Relevant log output

No response

amirvenus commented 6 months ago

Build log msbuild.binlog.zip

Project file tree filetree.txt

Thanks!

dellis1972 commented 6 months ago

@amirvenus have you tried adding the following package https://www.nuget.org/packages/Xamarin.Google.Android.Material ?

amirvenus commented 6 months ago

@amirvenus have you tried adding the following package https://www.nuget.org/packages/Xamarin.Google.Android.Material ?

That did the trick.

Is this documented? I was hoping the upgrade-assistant tool would take care of it itself

Thank you!

However, I had some other issues with the Resource generation so I had to use some workarounds and csproj properties