Skip to content

In app projects configured to use AAPT2, builds show incorrect file paths for AAPT2 errors caused by existing library projects built with AAPT that have Android resource elements that are now invalid with AAPT2 #3344

@brendanzagaeski

Description

@brendanzagaeski

Context: https://developercommunity.visualstudio.com/content/problem/635696/error-apt0000-inner-element-must-either-be-a-resou.html

Steps to reproduce

  1. Build the library project from the test case:

    msbuild -restore AndroidLibrary1\AndroidLibrary1.csproj
  2. Build the app project from the test case:

    msbuild -restore .\AndroidApp1\AndroidApp1.csproj

Test case: LibraryResourceAapt2ErrorPath.zip

The library project has $(AndroidUseAapt2) set to false, while the app project has $(AndroidUseAapt2) set to true.

Expected behavior

I'm not sure if resource_name_case_map is missing expected information in this scenario or if it's normal that there won't be a mapping for this kind of resource in a prebuilt library. Maybe when the AAPT2 error comes from a prebuilt library project, the best file path to use would be the original location in the obj\ directory that AAPT2 prints in the original unparsed error message. So the errors would look something like:

C:\Temp\LibraryResourceAaptErrorPath\AndroidApp1\obj\Debug\90\lp\0\jl\res\values\strings.xml(2): error APT0000: <item> inner element must either be a resource reference or empty. [C:\Temp\LibraryResourceAaptErrorPath\AndroidApp1\AndroidApp1.csproj]
C:\Temp\LibraryResourceAaptErrorPath\AndroidApp1\obj\Debug\90\lp\0\jl\res\values\strings.xml : error APT0000: file failed to compile. [C:\Temp\LibraryResourceAaptErrorPath\AndroidApp1\AndroidApp1.csproj]

Actual behavior

The errors show an incorrect file path, making it look like they are coming from the app project, when they are actually coming from the library project:

Resources\values\strings.xml(2): error APT0000: <item> inner element must either be a resource reference or empty. [C:\Temp\LibraryResourceAaptErrorPath\AndroidApp1\AndroidApp1.csproj]
Resources\values\strings.xml : error APT0000: file failed to compile. [C:\Temp\LibraryResourceAaptErrorPath\AndroidApp1\AndroidApp1.csproj]

Version information

Xamarin.Android SDK 9.5.0.26 (d16-3/f951e60)

Log file

msbuild.binlog.zip

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions