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

Csc errors in Resource.designer.cs during a regular build #3237

Closed
jonathanpeppers opened this issue Jun 17, 2019 · 2 comments · Fixed by #3315
Closed

Csc errors in Resource.designer.cs during a regular build #3237

jonathanpeppers opened this issue Jun 17, 2019 · 2 comments · Fixed by #3315
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects. bug Component does not function as intended.

Comments

@jonathanpeppers
Copy link
Member

Steps to Reproduce

Filing this, as I have not figured out what is wrong yet...

  1. Clone Xamarin.Forms or run git clean -dxf
  2. Run Xamarin.Forms.ControlGallery.Android -- a Xamarin.Android app project
  3. You might get compiler errors in activities using fields from Resource.designer.cs
Errors
    AppCompat\NavigationPageRenderer.cs(461,34): error CS0117: 'Resource.Attribute' does not contain a definition for 'actionBarSize' 
    Renderers\ShellItemRenderer.cs(60,45): error CS0117: 'Resource' does not contain a definition for 'Layout'
... plus more

Rebuilding Xamarin.Forms.ControlGallery.Android fixes the issue.

The actual file looked like this:

#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: global::Android.Runtime.ResourceDesignerAttribute("Xamarin.Forms.Platform.Android.Resource", IsApplication=false)]

namespace Xamarin.Forms.Platform.Android
{
	
	
	[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
	public partial class Resource
	{
		
		static Resource()
		{
			global::Android.Runtime.ResourceIdManager.UpdateIdValues();
		}
		
		public partial class Attribute
		{
			
			static Attribute()
			{
				global::Android.Runtime.ResourceIdManager.UpdateIdValues();
			}
			
			private Attribute()
			{
			}
		}
	}
}
#pragma warning restore 1591

In a working example, I see a lot of logs like this:

  - Not remapping resource: Animation.abc_fade_in
  - Not remapping resource: Animation.abc_fade_out
... plus many more

Those are absent in the failing build log.

Expected Behavior

A regular build should not encounter build errors.

Actual Behavior

You get build errors in code using Resource.designer.cs.

Version Information

@PureWeen was hitting this in VS Windows, using Xamarin.Android 9.4.0.34.

I wasn't able to reproduce myself, but logs are attached.

Log File

An example of a working/non-working build in here: aapt2.zip

@jonathanpeppers jonathanpeppers added bug Component does not function as intended. Area: App+Library Build Issues when building Library projects or Application projects. labels Jun 17, 2019
@jonathanpeppers jonathanpeppers added this to the d16-3 milestone Jun 17, 2019
@jonathanpeppers
Copy link
Member Author

I found out how to reproduce this command-line:

> git clean -dxf
> msbuild Xamarin.Forms.sln /restore /m

You can solve the issue by either removing /m (builds projects in parallel), or adding /p:AndroidUseAapt2=False.

Here is a log: error.zip

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Jul 2, 2019
Fixes: dotnet#3237

We have been made aware of a random error when building Xamarin.Forms
from source:

    Errors
        AppCompat\NavigationPageRenderer.cs(461,34): error CS0117: 'Resource.Attribute' does not contain a definition for 'actionBarSize'
        Renderers\ShellItemRenderer.cs(60,45): error CS0117: 'Resource' does not contain a definition for 'Layout'
    ... plus more

I was able to reproduce this in the IDE, but also with:

    > git clean -dxf
    > msbuild Xamarin.Forms.sln /restore /m

I could resolve the issue by either:

* Change the setting in the IDE to use 1 MSBuild node
* Remove `/m`, which builds in parallel
* Add `/p:AndroidUseAapt2=False`

After debugging, the problem appeared to be this file was completely
blank:

    Xamarin.Forms.Platform.Android\obj\Debug\90\R.txt

Then when I reviewed the `aapt2 link` call:

    Executing link --manifest C:\Users\jopepper\AppData\Local\Temp\dief34vx.ctw\manifest\AndroidManifest.xml --java C:\Users\jopepper\AppData\Local\Temp\dief34vx.ctw --custom-package xamarin.forms.platform.android --auto-add-overlay -I "C:\Program Files (x86)\Android\android-sdk\platforms\android-28\android.jar" --output-text-symbols obj\Debug\90\R.txt -o C:\Users\jopepper\AppData\Local\Temp\dief34vx.ctw\resources.apk

There were no `-R` arguments? This meant that the `.flata` files did
not exist at all??? Yet they *did* exist, and I could see them
generated in the log prior to this call...

I added logging and tried it again:

    Aapt2Link
    ...
        Archive does not exist: obj\Debug\90\flata\43df68e0d20944e28151b722a21d9b9ef640254e.flata
        Archive does not exist: obj\Debug\90\flata\74a3f1c210308ec085909c723a8990aa914c1a71.flata
        Archive does not exist: obj\Debug\90\flata\4db0a001e031ddf3be314c5355f4fbbc0ce43f64.flata
        Archive does not exist: obj\Debug\90\flata\b12a43cde6840d15dadec10f8fb3ca5c547acc69.flata
        Archive does not exist: obj\Debug\90\flata\3b2cd76e696829add57b46e563c7a78bb42b7b11.flata
        Archive does not exist: obj\Debug\90\flata\ba386569fd62aa4d06aae04e8fc5ea2f4c505ecb.flata
        Archive does not exist: obj\Debug\90\flata\5ad21817f3b88df6b142d14cfcd0aa60312a41f2.flata
        Archive does not exist: obj\Debug\90\flata\86863b3e6cc326508270b8c30f738959fb241678.flata
        Archive does not exist: obj\Debug\90\flata\6a09985ebabd8c9070c92b8338f9c6f6198d0f0a.flata
        Archive does not exist: obj\Debug\90\flata\02d2c22bddc9d6810e8dc8cbdbe03619212dddc0.flata
        Archive does not exist: obj\Debug\90\flata\081a2e056100d972d2fc4067acb8a5034ac9ac9c.flata
        Archive does not exist: obj\Debug\90\flata\bd1122dc1010f54688ad4b996adc4af4b964358a.flata
        Archive does not exist: obj\Debug\90\flata\\compiled.flata
        Executing link --manifest C:\Users\jopepper\AppData\Local\Temp\cxwzxiiv.he2\manifest\AndroidManifest.xml --java C:\Users\jopepper\AppData\Local\Temp\cxwzxiiv.he2 --custom-package xamarin.forms.maps.android --auto-add-overlay -I "C:\Program Files (x86)\Android\android-sdk\platforms\android-28\android.jar" --output-text-symbols obj\Debug\90\R.txt -o C:\Users\jopepper\AppData\Local\Temp\cxwzxiiv.he2\resources.apk

That is when I realized all these were relative paths. We need to be
using `AsyncTask.WorkingDirectory` here. After fixing that the problem
went away. I kept the logging as well, since it should be helpful in
the future.

Unfortunately, I don't see how to add a test for this issue, since the
`/m` switch does not work with `xabuild.exe` on Windows. MSBuild's
out-of-process node logic gets a bit confused.

We should revisit later, and add new MSBuild tests using `/m` after we
get the tests running against the system install on Azure DevOps.
dellis1972 pushed a commit that referenced this issue Jul 3, 2019
Fixes: #3237

We have been made aware of a random error when building Xamarin.Forms
from source:

    Errors
        AppCompat\NavigationPageRenderer.cs(461,34): error CS0117: 'Resource.Attribute' does not contain a definition for 'actionBarSize'
        Renderers\ShellItemRenderer.cs(60,45): error CS0117: 'Resource' does not contain a definition for 'Layout'
    ... plus more

I was able to reproduce this in the IDE, but also with:

    > git clean -dxf
    > msbuild Xamarin.Forms.sln /restore /m

I could resolve the issue by either:

* Change the setting in the IDE to use 1 MSBuild node
* Remove `/m`, which builds in parallel
* Add `/p:AndroidUseAapt2=False`

After debugging, the problem appeared to be this file was completely
blank:

    Xamarin.Forms.Platform.Android\obj\Debug\90\R.txt

Then when I reviewed the `aapt2 link` call:

    Executing link --manifest C:\Users\jopepper\AppData\Local\Temp\dief34vx.ctw\manifest\AndroidManifest.xml --java C:\Users\jopepper\AppData\Local\Temp\dief34vx.ctw --custom-package xamarin.forms.platform.android --auto-add-overlay -I "C:\Program Files (x86)\Android\android-sdk\platforms\android-28\android.jar" --output-text-symbols obj\Debug\90\R.txt -o C:\Users\jopepper\AppData\Local\Temp\dief34vx.ctw\resources.apk

There were no `-R` arguments? This meant that the `.flata` files did
not exist at all??? Yet they *did* exist, and I could see them
generated in the log prior to this call...

I added logging and tried it again:

    Aapt2Link
    ...
        Archive does not exist: obj\Debug\90\flata\43df68e0d20944e28151b722a21d9b9ef640254e.flata
        Archive does not exist: obj\Debug\90\flata\74a3f1c210308ec085909c723a8990aa914c1a71.flata
        Archive does not exist: obj\Debug\90\flata\4db0a001e031ddf3be314c5355f4fbbc0ce43f64.flata
        Archive does not exist: obj\Debug\90\flata\b12a43cde6840d15dadec10f8fb3ca5c547acc69.flata
        Archive does not exist: obj\Debug\90\flata\3b2cd76e696829add57b46e563c7a78bb42b7b11.flata
        Archive does not exist: obj\Debug\90\flata\ba386569fd62aa4d06aae04e8fc5ea2f4c505ecb.flata
        Archive does not exist: obj\Debug\90\flata\5ad21817f3b88df6b142d14cfcd0aa60312a41f2.flata
        Archive does not exist: obj\Debug\90\flata\86863b3e6cc326508270b8c30f738959fb241678.flata
        Archive does not exist: obj\Debug\90\flata\6a09985ebabd8c9070c92b8338f9c6f6198d0f0a.flata
        Archive does not exist: obj\Debug\90\flata\02d2c22bddc9d6810e8dc8cbdbe03619212dddc0.flata
        Archive does not exist: obj\Debug\90\flata\081a2e056100d972d2fc4067acb8a5034ac9ac9c.flata
        Archive does not exist: obj\Debug\90\flata\bd1122dc1010f54688ad4b996adc4af4b964358a.flata
        Archive does not exist: obj\Debug\90\flata\\compiled.flata
        Executing link --manifest C:\Users\jopepper\AppData\Local\Temp\cxwzxiiv.he2\manifest\AndroidManifest.xml --java C:\Users\jopepper\AppData\Local\Temp\cxwzxiiv.he2 --custom-package xamarin.forms.maps.android --auto-add-overlay -I "C:\Program Files (x86)\Android\android-sdk\platforms\android-28\android.jar" --output-text-symbols obj\Debug\90\R.txt -o C:\Users\jopepper\AppData\Local\Temp\cxwzxiiv.he2\resources.apk

That is when I realized all these were relative paths. We need to be
using `AsyncTask.WorkingDirectory` here. After fixing that the problem
went away. I kept the logging as well, since it should be helpful in
the future.

Unfortunately, I don't see how to add a test for this issue, since the
`/m` switch does not work with `xabuild.exe` on Windows. MSBuild's
out-of-process node logic gets a bit confused.

We should revisit later, and add new MSBuild tests using `/m` after we
get the tests running against the system install on Azure DevOps.
jonpryor pushed a commit that referenced this issue Jul 22, 2019
Fixes: #3237

We have been made aware of a random error when building Xamarin.Forms
from source:

    Errors
        AppCompat\NavigationPageRenderer.cs(461,34): error CS0117: 'Resource.Attribute' does not contain a definition for 'actionBarSize'
        Renderers\ShellItemRenderer.cs(60,45): error CS0117: 'Resource' does not contain a definition for 'Layout'
    ... plus more

I was able to reproduce this in the IDE, but also with:

    > git clean -dxf
    > msbuild Xamarin.Forms.sln /restore /m

I could resolve the issue by either:

* Change the setting in the IDE to use 1 MSBuild node
* Remove `/m`, which builds in parallel
* Add `/p:AndroidUseAapt2=False`

After debugging, the problem appeared to be this file was completely
blank:

    Xamarin.Forms.Platform.Android\obj\Debug\90\R.txt

Then when I reviewed the `aapt2 link` call:

    Executing link --manifest C:\Users\jopepper\AppData\Local\Temp\dief34vx.ctw\manifest\AndroidManifest.xml --java C:\Users\jopepper\AppData\Local\Temp\dief34vx.ctw --custom-package xamarin.forms.platform.android --auto-add-overlay -I "C:\Program Files (x86)\Android\android-sdk\platforms\android-28\android.jar" --output-text-symbols obj\Debug\90\R.txt -o C:\Users\jopepper\AppData\Local\Temp\dief34vx.ctw\resources.apk

There were no `-R` arguments? This meant that the `.flata` files did
not exist at all??? Yet they *did* exist, and I could see them
generated in the log prior to this call...

I added logging and tried it again:

    Aapt2Link
    ...
        Archive does not exist: obj\Debug\90\flata\43df68e0d20944e28151b722a21d9b9ef640254e.flata
        Archive does not exist: obj\Debug\90\flata\74a3f1c210308ec085909c723a8990aa914c1a71.flata
        Archive does not exist: obj\Debug\90\flata\4db0a001e031ddf3be314c5355f4fbbc0ce43f64.flata
        Archive does not exist: obj\Debug\90\flata\b12a43cde6840d15dadec10f8fb3ca5c547acc69.flata
        Archive does not exist: obj\Debug\90\flata\3b2cd76e696829add57b46e563c7a78bb42b7b11.flata
        Archive does not exist: obj\Debug\90\flata\ba386569fd62aa4d06aae04e8fc5ea2f4c505ecb.flata
        Archive does not exist: obj\Debug\90\flata\5ad21817f3b88df6b142d14cfcd0aa60312a41f2.flata
        Archive does not exist: obj\Debug\90\flata\86863b3e6cc326508270b8c30f738959fb241678.flata
        Archive does not exist: obj\Debug\90\flata\6a09985ebabd8c9070c92b8338f9c6f6198d0f0a.flata
        Archive does not exist: obj\Debug\90\flata\02d2c22bddc9d6810e8dc8cbdbe03619212dddc0.flata
        Archive does not exist: obj\Debug\90\flata\081a2e056100d972d2fc4067acb8a5034ac9ac9c.flata
        Archive does not exist: obj\Debug\90\flata\bd1122dc1010f54688ad4b996adc4af4b964358a.flata
        Archive does not exist: obj\Debug\90\flata\\compiled.flata
        Executing link --manifest C:\Users\jopepper\AppData\Local\Temp\cxwzxiiv.he2\manifest\AndroidManifest.xml --java C:\Users\jopepper\AppData\Local\Temp\cxwzxiiv.he2 --custom-package xamarin.forms.maps.android --auto-add-overlay -I "C:\Program Files (x86)\Android\android-sdk\platforms\android-28\android.jar" --output-text-symbols obj\Debug\90\R.txt -o C:\Users\jopepper\AppData\Local\Temp\cxwzxiiv.he2\resources.apk

That is when I realized all these were relative paths. We need to be
using `AsyncTask.WorkingDirectory` here. After fixing that the problem
went away. I kept the logging as well, since it should be helpful in
the future.

Unfortunately, I don't see how to add a test for this issue, since the
`/m` switch does not work with `xabuild.exe` on Windows. MSBuild's
out-of-process node logic gets a bit confused.

We should revisit later, and add new MSBuild tests using `/m` after we
get the tests running against the system install on Azure DevOps.
jonpryor pushed a commit that referenced this issue Jul 22, 2019
Fixes: #3237

We have been made aware of a random error when building Xamarin.Forms
from source:

    Errors
        AppCompat\NavigationPageRenderer.cs(461,34): error CS0117: 'Resource.Attribute' does not contain a definition for 'actionBarSize'
        Renderers\ShellItemRenderer.cs(60,45): error CS0117: 'Resource' does not contain a definition for 'Layout'
    ... plus more

I was able to reproduce this in the IDE, but also with:

    > git clean -dxf
    > msbuild Xamarin.Forms.sln /restore /m

I could resolve the issue by either:

* Change the setting in the IDE to use 1 MSBuild node
* Remove `/m`, which builds in parallel
* Add `/p:AndroidUseAapt2=False`

After debugging, the problem appeared to be this file was completely
blank:

    Xamarin.Forms.Platform.Android\obj\Debug\90\R.txt

Then when I reviewed the `aapt2 link` call:

    Executing link --manifest C:\Users\jopepper\AppData\Local\Temp\dief34vx.ctw\manifest\AndroidManifest.xml --java C:\Users\jopepper\AppData\Local\Temp\dief34vx.ctw --custom-package xamarin.forms.platform.android --auto-add-overlay -I "C:\Program Files (x86)\Android\android-sdk\platforms\android-28\android.jar" --output-text-symbols obj\Debug\90\R.txt -o C:\Users\jopepper\AppData\Local\Temp\dief34vx.ctw\resources.apk

There were no `-R` arguments? This meant that the `.flata` files did
not exist at all??? Yet they *did* exist, and I could see them
generated in the log prior to this call...

I added logging and tried it again:

    Aapt2Link
    ...
        Archive does not exist: obj\Debug\90\flata\43df68e0d20944e28151b722a21d9b9ef640254e.flata
        Archive does not exist: obj\Debug\90\flata\74a3f1c210308ec085909c723a8990aa914c1a71.flata
        Archive does not exist: obj\Debug\90\flata\4db0a001e031ddf3be314c5355f4fbbc0ce43f64.flata
        Archive does not exist: obj\Debug\90\flata\b12a43cde6840d15dadec10f8fb3ca5c547acc69.flata
        Archive does not exist: obj\Debug\90\flata\3b2cd76e696829add57b46e563c7a78bb42b7b11.flata
        Archive does not exist: obj\Debug\90\flata\ba386569fd62aa4d06aae04e8fc5ea2f4c505ecb.flata
        Archive does not exist: obj\Debug\90\flata\5ad21817f3b88df6b142d14cfcd0aa60312a41f2.flata
        Archive does not exist: obj\Debug\90\flata\86863b3e6cc326508270b8c30f738959fb241678.flata
        Archive does not exist: obj\Debug\90\flata\6a09985ebabd8c9070c92b8338f9c6f6198d0f0a.flata
        Archive does not exist: obj\Debug\90\flata\02d2c22bddc9d6810e8dc8cbdbe03619212dddc0.flata
        Archive does not exist: obj\Debug\90\flata\081a2e056100d972d2fc4067acb8a5034ac9ac9c.flata
        Archive does not exist: obj\Debug\90\flata\bd1122dc1010f54688ad4b996adc4af4b964358a.flata
        Archive does not exist: obj\Debug\90\flata\\compiled.flata
        Executing link --manifest C:\Users\jopepper\AppData\Local\Temp\cxwzxiiv.he2\manifest\AndroidManifest.xml --java C:\Users\jopepper\AppData\Local\Temp\cxwzxiiv.he2 --custom-package xamarin.forms.maps.android --auto-add-overlay -I "C:\Program Files (x86)\Android\android-sdk\platforms\android-28\android.jar" --output-text-symbols obj\Debug\90\R.txt -o C:\Users\jopepper\AppData\Local\Temp\cxwzxiiv.he2\resources.apk

That is when I realized all these were relative paths. We need to be
using `AsyncTask.WorkingDirectory` here. After fixing that the problem
went away. I kept the logging as well, since it should be helpful in
the future.

Unfortunately, I don't see how to add a test for this issue, since the
`/m` switch does not work with `xabuild.exe` on Windows. MSBuild's
out-of-process node logic gets a bit confused.

We should revisit later, and add new MSBuild tests using `/m` after we
get the tests running against the system install on Azure DevOps.
@brendanzagaeski
Copy link
Contributor

Release status update

A new Release version has now been published that includes the fix for this item.

Fix included in Xamarin.Android 10.0.0.43

Fix included on Windows in Visual Studio 2019 version 16.3. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.

Fix included on macOS in Visual Studio 2019 for Mac version 8.3. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 6, 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. bug Component does not function as intended.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants