Skip to content

Visual Studio Crashes when changing an AndroidResource file. #4734

@dellis1972

Description

@dellis1972

Context Developer Community 1038779:

There is a known issue in 16.7 Preview 1 where Visual Studio will crash unexpectedly when a Xamarin.Android project is in the solution. The issue on appears on projects which set the AndroidUseManagedDesignTimeResourceGenerator MSbuild property to False.

<AndroidUseManagedDesignTimeResourceGenerator>False</AndroidUseManagedDesignTimeResourceGenerator>

Workaround.

For now setting AndroidUseManagedDesignTimeResourceGenerator to True or removing the element completely fixes the issue.

Cause

As part of the effort to improve build times 16.7 Preview 1 uses the newer aapt2 daemon mode to compile resources. As part of this we need to set the InputEncoding for the process to be UTF8. This is so that paths which contain accents or special characters are interpreted correctly by aapt2. For some reason when doing a background Design Time build setting the InputEncoding is failing with the following exception.

System.IO.IOException: The handle is invalid.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.__Error.WinIOError()
   at System.Console.set_InputEncoding(Encoding value)
   at Xamarin.Android.Tasks.Aapt2Daemon.Aapt2DaemonStart()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Metadata

Metadata

Assignees

Labels

possibly-staleIssues that are potentially no longer relevant.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions