Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
brendanzagaeski opened this issue Jul 10, 2019 · 1 comment
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects.

Comments

@brendanzagaeski
Copy link
Contributor

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

@brendanzagaeski brendanzagaeski added the Area: App+Library Build Issues when building Library projects or Application projects. label Jul 10, 2019
@brendanzagaeski brendanzagaeski added this to the Under Consideration milestone Jul 10, 2019
@dellis1972
Copy link
Contributor

So the problem here is that the app has a strings.xml and one or more of the libraries also has a strings.xml. So our code which fixes up the paths is doing everything... So I guess it needs to be smarter so it only updates file paths for those files within the app itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
Development

No branches or pull requests

3 participants