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

[AAPT2] Encountering build errors due to missing Resource.* fields which aren't actually missing when aapt2 is enabled #2047

Closed
pjcollins opened this issue Aug 8, 2018 · 10 comments · Fixed by #2058
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects. vs-sync For internal use only; creates a VSTS "mirror" issue.
Milestone

Comments

@pjcollins
Copy link
Member

pjcollins commented Aug 8, 2018

I've got a handful of projects which are failing during CoreCompile due to Resource related errors when enabling aapt2. These errors appear to be falsely reported however, and don't occur when using aapt. There is also perhaps some relation with the issue described in #1983.

Steps to Reproduce

  1. Build ApiDemo and/or any of the other 4 projects shown in the "Actual Behavior" section with aapt2 enabled.

Expected Behavior

These projects should build successfully with aapt2 enabled.

Actual Behavior

http://xqa.blob.core.windows.net/gist/report-3c94cd9125164b8c89c5b1dafc5fab60.txt

  Activities/LoggingActivity.cs(122,46): error CS0117: 'Resource.Id' does not contain a definition for 'scrollview' [/Users/xamarinqa/myagent/_work/r5/a/monodroid-samples/android-n/MultiWindowPlayground/MultiWindowPlayground/MultiWindowPlayground.csproj]

http://xqa.blob.core.windows.net/gist/report-1e247c7717ac496891b088764c29eddc.txt

  View/ContentBrowserActivity.cs(155,41): error CS0117: 'Resource.Id' does not contain a definition for 'seekbar' [/Users/xamarinqa/myagent/_work/r5/a/monodroid-samples/ApiDemo/ApiDemo.csproj]
  View/ContentBrowserNavActivity.cs(158,41): error CS0117: 'Resource.Id' does not contain a definition for 'seekbar' [/Users/xamarinqa/myagent/_work/r5/a/monodroid-samples/ApiDemo/ApiDemo.csproj]

http://xqa.blob.core.windows.net/gist/report-85670af60ea046d48d66409f4442f0ee.txt

  MainActivity.cs(24,44): error CS0117: 'Resource.Layout' does not contain a definition for 'Main' [/Users/xamarinqa/myagent/_work/r5/a/monodroid-samples/Firebase/FCMNotifications/FCMNotifications/FCMNotifications.csproj]
  MainActivity.cs(25,58): error CS0117: 'Resource.Id' does not contain a definition for 'msgText' [/Users/xamarinqa/myagent/_work/r5/a/monodroid-samples/Firebase/FCMNotifications/FCMNotifications/FCMNotifications.csproj]
  MainActivity.cs(42,67): error CS0117: 'Resource.Id' does not contain a definition for 'logTokenButton' [/Users/xamarinqa/myagent/_work/r5/a/monodroid-samples/Firebase/FCMNotifications/FCMNotifications/FCMNotifications.csproj]
  MainActivity.cs(44,68): error CS0117: 'Resource.Id' does not contain a definition for 'subscribeButton' [/Users/xamarinqa/myagent/_work/r5/a/monodroid-samples/Firebase/FCMNotifications/FCMNotifications/FCMNotifications.csproj]
  MyFirebaseMessagingService.cs(41,71): error CS0117: 'Resource.Drawable' does not contain a definition for 'ic_stat_ic_notification' [/Users/xamarinqa/myagent/_work/r5/a/monodroid-samples/Firebase/FCMNotifications/FCMNotifications/FCMNotifications.csproj]

http://xqa.blob.core.windows.net/gist/report-827877f595704e708224b2a8802d0c53.txt

  MainActivity.cs(60,58): error CS0117: 'Resource.Id' does not contain a definition for 'alt' [/Users/xamarinqa/myagent/_work/r5/a/mobile-samples/BackgroundLocationDemo/location.Android/Location.Droid.csproj]

http://xqa.blob.core.windows.net/gist/report-aee90b21f9e440108a605cd8dac73567.txt

  MainActivity.cs(15,49): error CS0117: 'Resource.Layout' does not contain a definition for 'Tabbar' [/Users/xamarinqa/myagent/_work/r5/a/xamarin-forms-samples/WebServices/TodoAzurePush/Droid/TodoAzure.Droid.csproj]
  MainActivity.cs(16,47): error CS0117: 'Resource.Layout' does not contain a definition for 'Toolbar' [/Users/xamarinqa/myagent/_work/r5/a/xamarin-forms-samples/WebServices/TodoAzurePush/Droid/TodoAzure.Droid.csproj]
  Services/FirebaseNotificationService.cs(36,49): error CS0117: 'Resource.Drawable' does not contain a definition for 'ic_stat_ic_notification' [/Users/xamarinqa/myagent/_work/r5/a/xamarin-forms-samples/WebServices/TodoAzurePush/Droid/TodoAzure.Droid.csproj]

Version Information

xamarin-android/d15-9

VS bug #660872

@pjcollins pjcollins added the Area: App+Library Build Issues when building Library projects or Application projects. label Aug 8, 2018
@pjcollins pjcollins added this to the d15-9 milestone Aug 8, 2018
@pjcollins pjcollins added the vs-sync For internal use only; creates a VSTS "mirror" issue. label Aug 8, 2018
@dellis1972 dellis1972 self-assigned this Aug 8, 2018
@dellis1972
Copy link
Contributor

So looking at the ApiDemo issue.. we have this problem

Resources/layout/animation_seeking.xml has a item with id = android:id="@+id/seekBar"
Resources/layout/content_browser.xml has id = android:id="@+id/seekbar"
Resources/layout/content_browser_nav.xml has id = android:id="@+id/seekbar"

the old system ended up with both seekbar AND seekBar in the resource designer.

This is confirmed by looking at the R.txt which has

int id seekBar 0x7f08018e
int id seekbar 0x7f08018f

Our ManagedResourceParser does NOT allow for items with different casing [1]. As a result the first item it comes across will win. Which means the code using the other casing will fail.
I will try to make the Parser case sensitive and see what that breaks.

[1] https://github.com/xamarin/xamarin-android/blob/master/src/Xamarin.Android.Build.Tasks/Utilities/ManagedResourceParser.cs#L324

dellis1972 added a commit to dellis1972/xamarin-android that referenced this issue Aug 13, 2018
Fixes dotnet#2047

When we implemented the `ManagedResouceParser` the initial thought
was that all the fields we present would be unique. So when we
checked to see if the container class already had a field with
the same name we uses a Case Insensitive comparision to do that.

We a result this broke a number of sample applicaitons that QA have.
Looking at the `ApiDemo` issue.. we have this problem

	Resources/layout/animation_seeking.xml` has a item with id = `android:id="@+id/seekBar"
	Resources/layout/content_browser.xml` has id = `android:id="@+id/seekbar"
	Resources/layout/content_browser_nav.xml` has id = `android:id="@+id/seekbar"

Note the different casing for `seekBar`. With the old `aapt` based
R.java resource parser this results in BOTH `seekbar` and `seekBar`
being available in the `Resource.Desogner.cs` file.

Because of the Case Insensitive check in the new parser these two
fields are merged into one. It would be on a first found basis.
So if `seekBar` was the first field added , then that is exposed.
The other `seebar` field would be ignored.

We might see this as a problem in our parser but aapt and aapt2 both
produce the following in the `R.txt` file

	int id seekBar 0x7f08018e
	int id seekbar 0x7f08018f

So the fix in this case is to just do a normal case check to ensure
that if we have fields with different casing, they are handled
correctly.
@dellis1972
Copy link
Contributor

PR #2058 is up

dellis1972 added a commit to dellis1972/xamarin-android that referenced this issue Aug 14, 2018
Fixes dotnet#2047

When we implemented the `ManagedResouceParser` the initial thought
was that all the fields we present would be unique. So when we
checked to see if the container class already had a field with
the same name we uses a Case Insensitive comparision to do that.

We a result this broke a number of sample applicaitons that QA have.
Looking at the `ApiDemo` issue.. we have this problem

	Resources/layout/animation_seeking.xml` has a item with id = `android:id="@+id/seekBar"
	Resources/layout/content_browser.xml` has id = `android:id="@+id/seekbar"
	Resources/layout/content_browser_nav.xml` has id = `android:id="@+id/seekbar"

Note the different casing for `seekBar`. With the old `aapt` based
R.java resource parser this results in BOTH `seekbar` and `seekBar`
being available in the `Resource.Desogner.cs` file.

Because of the Case Insensitive check in the new parser these two
fields are merged into one. It would be on a first found basis.
So if `seekBar` was the first field added , then that is exposed.
The other `seebar` field would be ignored.

We might see this as a problem in our parser but aapt and aapt2 both
produce the following in the `R.txt` file

	int id seekBar 0x7f08018e
	int id seekbar 0x7f08018f

So the fix in this case is to just do a normal case check to ensure
that if we have fields with different casing, they are handled
correctly.
dellis1972 added a commit to dellis1972/xamarin-android that referenced this issue Aug 14, 2018
Fixes dotnet#2047

When we implemented the `ManagedResouceParser` the initial thought
was that all the fields we present would be unique. So when we
checked to see if the container class already had a field with
the same name we uses a Case Insensitive comparision to do that.

We a result this broke a number of sample applicaitons that QA have.
Looking at the `ApiDemo` issue.. we have this problem

	Resources/layout/animation_seeking.xml` has a item with id = `android:id="@+id/seekBar"
	Resources/layout/content_browser.xml` has id = `android:id="@+id/seekbar"
	Resources/layout/content_browser_nav.xml` has id = `android:id="@+id/seekbar"

Note the different casing for `seekBar`. With the old `aapt` based
R.java resource parser this results in BOTH `seekbar` and `seekBar`
being available in the `Resource.Desogner.cs` file.

Because of the Case Insensitive check in the new parser these two
fields are merged into one. It would be on a first found basis.
So if `seekBar` was the first field added , then that is exposed.
The other `seebar` field would be ignored.

We might see this as a problem in our parser but aapt and aapt2 both
produce the following in the `R.txt` file

	int id seekBar 0x7f08018e
	int id seekbar 0x7f08018f

So the fix in this case is to just do a normal case check to ensure
that if we have fields with different casing, they are handled
correctly.
dellis1972 added a commit to dellis1972/xamarin-android that referenced this issue Aug 15, 2018
Fixes dotnet#2047

When we implemented the `ManagedResouceParser` the initial thought
was that all the fields we present would be unique. So when we
checked to see if the container class already had a field with
the same name we uses a Case Insensitive comparision to do that.

We a result this broke a number of sample applicaitons that QA have.
Looking at the `ApiDemo` issue.. we have this problem

	Resources/layout/animation_seeking.xml` has a item with id = `android:id="@+id/seekBar"
	Resources/layout/content_browser.xml` has id = `android:id="@+id/seekbar"
	Resources/layout/content_browser_nav.xml` has id = `android:id="@+id/seekbar"

Note the different casing for `seekBar`. With the old `aapt` based
R.java resource parser this results in BOTH `seekbar` and `seekBar`
being available in the `Resource.Desogner.cs` file.

Because of the Case Insensitive check in the new parser these two
fields are merged into one. It would be on a first found basis.
So if `seekBar` was the first field added , then that is exposed.
The other `seebar` field would be ignored.

We might see this as a problem in our parser but aapt and aapt2 both
produce the following in the `R.txt` file

	int id seekBar 0x7f08018e
	int id seekbar 0x7f08018f

So the fix in this case is to just do a normal case check to ensure
that if we have fields with different casing, they are handled
correctly.
dellis1972 added a commit to dellis1972/xamarin-android that referenced this issue Aug 23, 2018
Fixes dotnet#2047

When we implemented the `ManagedResouceParser` the initial thought
was that all the fields we present would be unique. So when we
checked to see if the container class already had a field with
the same name we uses a Case Insensitive comparision to do that.

We a result this broke a number of sample applicaitons that QA have.
Looking at the `ApiDemo` issue.. we have this problem

	Resources/layout/animation_seeking.xml` has a item with id = `android:id="@+id/seekBar"
	Resources/layout/content_browser.xml` has id = `android:id="@+id/seekbar"
	Resources/layout/content_browser_nav.xml` has id = `android:id="@+id/seekbar"

Note the different casing for `seekBar`. With the old `aapt` based
R.java resource parser this results in BOTH `seekbar` and `seekBar`
being available in the `Resource.Desogner.cs` file.

Because of the Case Insensitive check in the new parser these two
fields are merged into one. It would be on a first found basis.
So if `seekBar` was the first field added , then that is exposed.
The other `seebar` field would be ignored.

We might see this as a problem in our parser but aapt and aapt2 both
produce the following in the `R.txt` file

	int id seekBar 0x7f08018e
	int id seekbar 0x7f08018f

So the fix in this case is to just do a normal case check to ensure
that if we have fields with different casing, they are handled
correctly.
dellis1972 added a commit that referenced this issue Aug 24, 2018
…2058)

Fixes #2047

When we implemented the `ManagedResouceParser` the initial thought
was that all the fields we present would be unique. So when we
checked to see if the container class already had a field with
the same name we uses a Case Insensitive comparision to do that.

We a result this broke a number of sample applicaitons that QA have.
Looking at the `ApiDemo` issue.. we have this problem

	Resources/layout/animation_seeking.xml` has a item with id = `android:id="@+id/seekBar"
	Resources/layout/content_browser.xml` has id = `android:id="@+id/seekbar"
	Resources/layout/content_browser_nav.xml` has id = `android:id="@+id/seekbar"

Note the different casing for `seekBar`. With the old `aapt` based
R.java resource parser this results in BOTH `seekbar` and `seekBar`
being available in the `Resource.Desogner.cs` file.

Because of the Case Insensitive check in the new parser these two
fields are merged into one. It would be on a first found basis.
So if `seekBar` was the first field added , then that is exposed.
The other `seebar` field would be ignored.

We might see this as a problem in our parser but aapt and aapt2 both
produce the following in the `R.txt` file

	int id seekBar 0x7f08018e
	int id seekbar 0x7f08018f

So the fix in this case is to just do a normal case check to ensure
that if we have fields with different casing, they are handled
correctly.
jonpryor pushed a commit that referenced this issue Sep 5, 2018
…2058)

Fixes #2047

When we implemented the `ManagedResouceParser` the initial thought
was that all the fields we present would be unique. So when we
checked to see if the container class already had a field with
the same name we uses a Case Insensitive comparision to do that.

We a result this broke a number of sample applicaitons that QA have.
Looking at the `ApiDemo` issue.. we have this problem

	Resources/layout/animation_seeking.xml` has a item with id = `android:id="@+id/seekBar"
	Resources/layout/content_browser.xml` has id = `android:id="@+id/seekbar"
	Resources/layout/content_browser_nav.xml` has id = `android:id="@+id/seekbar"

Note the different casing for `seekBar`. With the old `aapt` based
R.java resource parser this results in BOTH `seekbar` and `seekBar`
being available in the `Resource.Desogner.cs` file.

Because of the Case Insensitive check in the new parser these two
fields are merged into one. It would be on a first found basis.
So if `seekBar` was the first field added , then that is exposed.
The other `seebar` field would be ignored.

We might see this as a problem in our parser but aapt and aapt2 both
produce the following in the `R.txt` file

	int id seekBar 0x7f08018e
	int id seekbar 0x7f08018f

So the fix in this case is to just do a normal case check to ensure
that if we have fields with different casing, they are handled
correctly.
@pjcollins
Copy link
Member Author

@pjcollins pjcollins reopened this Oct 9, 2018
@dellis1972
Copy link
Contributor

@pjcollins hmm. Just tested this on master and the TodoAzurePush sample works.... :/

@pjcollins
Copy link
Member Author

@dellis1972 I just tested this locally against monodroid/master/6b8f18a24 (9.1.199.5) and am still able to reproduce the errors in the two samples mentioned above, although I am on Windows. Did you manage to try the Firebase sample as well?

Binary and diagnostic logs

@dellis1972
Copy link
Contributor

@pjcollins the problem is 960f32c

We are too late for a d15-9 cp now are we not?

@dellis1972
Copy link
Contributor

So the problem is the google play stuff is causing the main compiled.flata archive to NOT be created. As a result it will be missing a ton of resources. The commit 960f32c fixes all of that.

@pjcollins
Copy link
Member Author

@dellis1972 oh ok thanks, it looks like this one was CP'd to d15-9 (9102a47) so I'll have to wait for a new build. Marking as resolved for now.

@pjcollins
Copy link
Member Author

This is resolved on both windows and macos in D15-9 Preview 4 👍

@pfedotovsky
Copy link

When this fix will be released?

@ghost ghost locked as resolved and limited conversation to collaborators Jun 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects. vs-sync For internal use only; creates a VSTS "mirror" issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants