Bug 42373 - Breaking changes in Xamarin.Android 6.1 - Xamarin.Auth no longer compiles
Summary: Breaking changes in Xamarin.Android 6.1 - Xamarin.Auth no longer compiles
Status: RESOLVED ANSWERED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: unspecified
Hardware: PC Windows
: --- critical
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2016-07-06 01:00 UTC by Paul Batum
Modified: 2016-07-06 02:47 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Paul Batum 2016-07-06 01:00:48 UTC
# Steps to reproduce
- Clone https://github.com/xamarin/xamarin.auth
- Attempt to build (master branch) on Xamarin.Android 6.1 

# Expected behavior
Code builds successfully (as it did in prior versions of X.A)

# Actual behavior
Many compiler errors, all along the same lines of: The type or namespace name 'Graphics' does not exist in the namespace 'Xamarin.Android' (are you missing an assembly reference?)

# Supplemental info (logs, images, videos)
This appears to be a regression/breaking change. The same code compiled fine on earlier versions of Xamarin.Android. Another customer reported the same issue with no response here: https://forums.xamarin.com/discussion/69869/android-content-and-android-graphics-missing-an-assembly-reference

This is causing us severe problems. The Azure Mobile Services / Apps client SDK uses Xamarin.Auth as a git submodule, our builds are broken since installing VS Update 2 on our build machines.

I have found manual code changes that fix the build, but they are going to be very painful to implement (large PR to Xamarin.Auth). I would strongly prefer not to do this. 

The code in question getting build errors look like this:

                     public override void OnPageStarted (WebView view, string url, Android.Graphics.Bitmap favicon)
                     {
                           var uri = new Uri (url);
                           activity.state.Authenticator.OnPageLoading (uri);
                           activity.BeginProgress (uri.Authority);
                    }

Example error:
Error	CS0234	The type or namespace name 'Graphics' does not exist in the namespace 'Xamarin.Android' (are you missing an assembly reference?)	Xamarin.Auth.Android	D:\code\Xamarin.Auth\src\Xamarin.Auth.Android\WebAuthenticatorActivity.cs	165	Active

I can fix them, by adding global:: at the front of “Android.Graphics.Bitmap”. So the code becomes:

                     public override void OnPageStarted (WebView view, string url, global::Android.Graphics.Bitmap favicon)
                     {
                           var uri = new Uri (url);
                           activity.state.Authenticator.OnPageLoading (uri);
                           activity.BeginProgress (uri.Authority);
                     }



# Test environment (full version information)
Microsoft Visual Studio Enterprise 2015
Version 14.0.25421.03 Update 3
Microsoft .NET Framework
Version 4.6.01038

Installed Version: Enterprise

Architecture and Modeling Tools   00322-80000-00000-AA091
Microsoft Architecture and Modeling Tools
    
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

Visual Basic 2015   00322-80000-00000-AA091
Microsoft Visual Basic 2015

Visual C# 2015   00322-80000-00000-AA091
Microsoft Visual C# 2015

Visual C++ 2015   00322-80000-00000-AA091
Microsoft Visual C++ 2015

Visual F# 2015   00322-80000-00000-AA091
Microsoft Visual F# 2015

Windows Phone SDK 8.0 - ENU   00322-80000-00000-AA091
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   7.0.20622.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015 (RC1 Update 1)   14.1.11120.0
ASP.NET and Web Tools 2015 (RC1 Update 1)

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

Azure App Service Tools v2.8.1   14.0.11123.0
Azure App Service Tools v2.8.1

Common Azure Tools   1.8
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

DataFactoryProject   1.0
Microsoft Data Factory Package

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

Microsoft Azure Data Factory Node Node   1.0
Azure Data Factory extension for Visual Studio Server Explorer.

Microsoft Azure HDInsight HQL Service   2.0.2900.0
Language service for Hive query

Microsoft Azure HDInsight Tools for Visual Studio   2.0.2900.0
An integrated development environment for HDInsight application development.

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools   2.8
Microsoft Azure Tools for Microsoft Visual Studio 2015 - v2.8.31121.1

Microsoft Azure Tools   2.7
Microsoft Azure Tools for Microsoft Visual Studio 2015 - v2.7.30818.1601

NuGet Package Manager   3.4.4
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   14.0.60519.0
Microsoft SQL Server Data Tools

TypeScript   1.8.34.0
TypeScript tools for Visual Studio

Visual Studio Tools for Apache Cordova   Update 10
Visual Studio Tools for Apache Cordova

Visual Studio Tools for Universal Windows Apps   14.0.25420.01
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin   4.1.0.530 (2e39740)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   6.1.0.71 (4e27558)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   9.8.0.323 (39ebb77)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 1 Jonathan Pryor 2016-07-06 02:47:23 UTC
The "problem" is due to the introduction of the new Xamarin.Android.Net.AndroidClientHandler type, in the Xamarin.Android.Net namespace:

https://developer.xamarin.com/releases/android/xamarin.android_6/xamarin.android_6.1/#Native_HttpClientHandler

Because this is adds a Xamarin.Android.Net namespace, and because the xamarin.auth source uses a top-level `Xamarin` namespace-part, the normal C# type resolution rules will attempt to bind `Android.Graphics.Bitmap` as `Xamarin.Android.Graphics.Bitmap`, which doesn't exist.

There are two possible fixes:

1. Use `global::`:

    public override void OnPageStarted (
        WebView view,
        string url,
        global::Android.Graphics.Bitmap favicon)

2. Add a `using Android.Graphics;` to the top of the file, and use `Bitmap` instead of `Android.Graphics.Bitmap` within `OnPageStarted()`.