Bug 24497 - Certain APIs break linking due to inter-API-level differences.
Summary: Certain APIs break linking due to inter-API-level differences.
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 4.20.0
Hardware: PC Mac OS
: High critical
Target Milestone: 5.0
Assignee: Jonathan Pryor
Depends on:
Reported: 2014-11-13 12:59 UTC by Jonathan Pryor
Modified: 2014-12-04 11:32 UTC (History)
4 users (show)

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

Scratch.InterApiLevelChanges.zip (17.49 KB, application/zip)
2014-11-13 12:59 UTC, Jonathan Pryor

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:

Description Jonathan Pryor 2014-11-13 12:59:39 UTC
Created attachment 8720 [details]

There are some obscure differences in API binding between API levels which can cause the linker to break.


1. Download Scratch.InterApiLevelChanges.zip.

2. Unzip:

    unzip Scratch.InterApiLevelChanges.zip

3. Build:

    xbuild /t:SignAndroidPackage /p:Configuration=Release

Expected results: It should build!

Actual results: it doesn't:

> /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets:
> error : Error executing task LinkAssemblies:
> error XA2006: Reference to metadata item 'System.Boolean Android.Views.View::FitsSystemWindows()'
> (defined in 'UsesViewFitsSystemWindows, Version=, Culture=neutral, PublicKeyToken=null') from
> 'UsesViewFitsSystemWindows, Version=, Culture=neutral, PublicKeyToken=null' could not be resolved.

The cause for the error is that in API-15, which the attached Library project builds against, Android.Views.View.FitsSystemWindows() is a method. In API-16+, this is a *property*. Consequently, THERE IS NO Android.Views.View.FitsSystemWindows() method, and the linker fails.
Comment 1 Jonathan Pryor 2014-11-21 12:47:45 UTC
Fixed in monodroid/99b2bd88, which adds inter-API level API breakage checking on every Wrench build, to check for (and prevent?) future breakage in the future.

Then there's View.fitsSystemWindows() method, which is itself broken for other reasons: it's only present in API levels 14 and 15; Google *removed* the View.fitsSystemWindows() method in API-16.

This is "solved" via yet more ABI breaks. The API-15 binding will contain a View.FitsSystemWindows() method, which is [Obsolete(IsError=true)], so that accessing the member will result in compilation error.

We also add a View.InvokeFitsSystemWindows() method, which is also [Obsolete] but without the IsError setting, warning that the method only exists in API 14 & 15. This allows the method to be accessed if necessary.
Comment 2 Prashant manu 2014-11-28 01:34:30 UTC
We have checked as per steps in the description and still getting same error 'Error executing task LinkAssemblies: > error XA2006'
Hence reopening this issue.
Terminal Output: 
IDE log: 

Environment Info:
Xamarin Studio
Version 5.7 (build 596)
Installation UUID: ff0c16c6-3c75-46d8-ac56-56c3b56e2c76
	Mono 3.12.0 ((detached/b75fa2b)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000046

Apple Developer Tools
Xcode 6.1 (6604)
Build 6A1052d

Version: (Business Edition)
Hash: 880cc21
Build date: 2014-11-25 12:12:17-0500

Version: (Business Edition)
Android SDK: /Users/360_macmini/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

Version: (Business Edition)

Build Information
Release ID: 507000596
Git revision: d996e9ba6874a0d64241e43e5e6b06322ce29c84
Build date: 2014-11-25 17:17:54-05
Xamarin addins: 8ca19707b41536a391f53364ee4ff9272711feb0

Operating System
Mac OS X 10.10.0
Darwin Apples-iMac.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 3 Jonathan Pryor 2014-12-01 16:35:54 UTC

Please *clean* your project, fully. You should not be getting an XA2006 error; you should be getting CS0619 error:

> InterApiChanges.cs(11,13): error CS0619: 
> `Android.Views.View.FitsSystemWindows()' is obsolete: `The View.fitsSystemWindows() method was REMOVED by Google in API-16. DO NOT USE.)'

As It Happens™ View.fitsSystemWindows() is a bizarro member that Google themselves broke compatibility with, so if an app actually uses that member it is unlikely to run on anything later than API-15, which is *ancient* at this point in time.

The "workaround" for this member is to [Obsolete] View.FitsSystemWindows() with ObsoleteAttribute.IsError==true (hence the above CS0619 error), and re-introduce the "same" method as View.InvokeFitsSystemWindows()...which is *also* [Obsolete] but is *not* IsError. The latter is the same name that API-16+ has.

Given that Google broke compatibility here, the above seems a reasonable solution.
Comment 4 Ram Chandra 2014-12-04 11:32:13 UTC
@Jonathan: Thank you very much for the clarification. 

I have checked this issue with following builds:

Mac OS X 10.10.0
Xamarin Studio: 5.7 (build 612)
Mono 3.12.0 ((detached/b75fa2b)
GTK+ 2.24.23 (Raleigh theme)
=== Build Information ===

Release ID: 507000612
Git revision: eac2e66a14cd80fb6fa9552ee4a6bbdff6f22fe9
Build date: 2014-11-28 12:39:07-05
Xamarin addins: dfcd31a0b45bc27aa9e2091dee6192483c92a1e1

When I build the project with "View.FitsSystemWindows ();" I am getting following build error. (as mentioned in Comment 3)

> error CS0619: `Android.Views.View.FitsSystemWindows()' is obsolete: `The .   View.fitsSystemWindows() method was REMOVED by Google in API-16. DO NOT USE.)'"

I have replaced the "View.fitsSystemWindows()" with "v.InvokeFitsSystemWindows();" and build the application with following commend and observed that I am not getting any build error. Application builds successfully.

>    xbuild /t:SignAndroidPackage /p:Configuration=Release

Screencast: http://www.screencast.com/t/wpuP1tdA

Terminal Output: https://gist.github.com/Ram360Logica/91925a54c51601539910

This issue has been fixed. Hence I am closing this issue.