You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Mono.Android] Use Android platform api-versions.xml (#4186)
A "funny" thing happened when we bumped `$(XAPlatformToolsVersion)`
in PR #4012: ~all of the API compat checks started failing!
AfterBuild:
CheckApiCompatibility for ApiLevel: v10.0
CompatApi command: ../../packages/Microsoft.DotNet.ApiCompat.5.0.0-beta.19606.1/tools/net472/Microsoft.DotNet.ApiCompat.exe "../../tests/api-compatibility\reference\ApiCompatTemp" -i "F:\A\xamarin-v000006-1\_work\2\s\bin\Release\lib\xamarin.android\xbuild-frameworks\MonoAndroid\v10.0\ApiCompatTemp" --exclude-attributes ../../tests/api-compatibility\api-compat-exclude-attributes.txt
Compat issues with assembly Mono.Android:
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'System.String Android.Manifest.Permission.AccessBackgroundLocation' changed from '[RegisterAttribute("ACCESS_BACKGROUND_LOCATION")]' in the contract to '[RegisterAttribute("ACCESS_BACKGROUND_LOCATION", ApiSince=29)]' in the implementation.
...
The API compat checks are failing because of the *introduction* of
`RegisterAttribute.ApiSince` property values for members added in
API-29, and these errors didn't "make sense" to use because we had
expected all these members to *already* have `ApiSince=29`!
What Went Wrong™?
For starters, our memory and expectations were...incomplete.
`RegisterAttribute.ApiSince` is set based on the contents of the
Android SDK file `platform-tools/api/api-versions.xml`, which is part
of the "platform-tools" package.
Turns Out™ that `api-versions.xml` was *not* updated by Google when
the platform-tools package was updated to r29. Specifically, the
`platform-tools/api/api-versions.xml` file within
`platform-tools_r29.0.1-darwin.zip` doesn't contain *any* members
from API-29, and `RegisterAttribute.ApiSince` is only emitted when
the member is found within `api-versions.xml`.
This explains why PR #4012 "caused" the API breakage: The
platform-tools r29.0.5 package *does* contain an `api-versions.xml`
which contains API-29 members; thus updating platform-tools "caused"
the emission of the `RegisterAttribute.ApiSince` property values.
Which is a long-winded way of saying that *we cannot trust* the
`api-versions.xml` file within the platform-tools package.
With that trust lost, what do we use instead? There is another set
of `api-version.xml` files: starting with API-26, there are
`platforms/android-*/data/api-versions.xml` files. Furthermore, the
`api-versions.xml` file included with API-Q -- the preview for API-29
-- *did* contain the members added in API-29, and *did* indicate that
those members were added in API-29. As such, we do consider this
source of data to be trustworthy (this week, anyway).
Update `Mono.Android.targets` to use
`$(AndroidSdkDirectory)\platforms\android-$(AndroidApiLevel)\data\api-versions.xml`
for `RegisterAttribute.ApiSince` information, if it exists. If it
doesn't exist, we fallback and use the previously used platform-tools
copy of `api-versions.xml`.
Finally, two related changes:
1. Update to use `Microsoft.DotNet.GenAPI` and
`Microsoft.DotNet.ApiCompat` package versions of
5.0.0-beta.20078.1, up from 5.0.0-beta.20078.1.
This was done as it supposedly contains performance improvements.
2. Improve the mono crash detection from 5b1422c. With 5b1422c,
sometimes there would be "odd behavior" when re-using the same
`Process` object after the crash was detected. The `Process`
usage recommendation is to use a new `Process` object for each
process invocation; implement this recommendation.
Copy file name to clipboardExpand all lines: build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs
0 commit comments