Skip to content

Commit 3a9f14c

Browse files
committed
[build] Use platform-tools r31
Context: dotnet/java-interop#897 Context: f6011d9 Commit f6011d9 updated external/xamarin-android-tools so that the Android SDK platform-tools r31.0.3 package would be preferred, but *didn't* update `$(XAPlatformToolsVersion)` to cause the xamarin-android build to use platform-tools r31.0.3, because: > The reason to *not* bump `$(XAPlatformToolsVersion)` is that > attempting to do so breaks the `src/Mono.Android` build: > > 1. platform-tools r31.0.3 doesn't contain > `platform-tools/api/annotations.zip`, which is used by > `generator` to emit certain custom attributes such as > `RequiresPermission`. > > 2. While (1) can be worked around by instead using > `$(AndroidSdkDirectory)/platforms/android-*/data/annotations.zip`, > this introduces API changes reported by the > `_CheckApiCompatibility` target, in particular changes due to > custom attribute string changes. These string changes happen > because Google ships *invalid XML* in `data/annotations.zip` for > API-29+ (?!): dotnet/java-interop#897 is a proposed fix for (2), and should allow us to use platform-tools r31.0.3 for the xamarin-android build. WIP WIP WIP WIP Context: dotnet/java-interop#897 (comment) This does not fully build for me locally, because "duplicate" custom attributes are being emitted: $ diff -u obj/Debug/monoandroid10/android-{27,28}/mcw/Android.App.WallpaperManager.cs @@ -553,7 +553,7 @@ // Metadata.xml XPath method reference: path="/api/package[@name='android.app']/class[@name='WallpaperManager']/method[@name='clear' and count(parameter)=1 and parameter[1][@type='int']]" [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android24.0")] [Register ("clear", "(I)V", "GetClear_IHandler", ApiSince = 24)] - [global::Android.Runtime.RequiresPermission ("android.permission.SET_WALLPAPER")] + [global::Android.Runtime.RequiresPermission ("android.permission.SET_WALLPAPER")][global::Android.Runtime.RequiresPermission ("android.permission.SET_WALLPAPER")] public virtual unsafe void Clear ([global::Android.Runtime.GeneratedEnum] Android.App.WallpaperManagerFlags which) { const string __id = "clear.(I)V"; resulting in errors such as: CannotChangeAttribute : Attribute 'Android.Runtime.RequiresPermissionAttribute' on 'Android.App.WallpaperManager.Clear(Android.App.WallpaperManagerFlags)' changed from '[RequiresPermissionAttribute("android.permission.SET_WALLPAPER")]' in the contract to '[RequiresPermissionAttribute("android.permission.SET_WALLPAPER")]' in the implementation. We should similarly fixup `generator` so that these duplicate custom attributes are *not* emitted.
1 parent 43243b4 commit 3a9f14c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Mono.Android/Mono.Android.targets

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,15 @@
135135
</Target>
136136
<Target Name="_GenerateBinding"
137137
BeforeTargets="CoreCompile"
138-
Inputs="metadata;enumflags;map.csv;methodmap.csv;$(IntermediateOutputPath)mcw\api.xml"
138+
Inputs="$(MSBuildThisFileFullPath);metadata;enumflags;map.csv;methodmap.csv;$(IntermediateOutputPath)mcw\api.xml"
139139
Outputs="$(IntermediateOutputPath)mcw\Mono.Android.projitems">
140140
<MakeDir Directories="$(IntermediateOutputPath)mcw" />
141141
<PropertyGroup>
142142
<_PlatformIdVersions>$(AndroidSdkDirectory)\platforms\android-$(AndroidPlatformId)\data\api-versions.xml</_PlatformIdVersions>
143+
<_AndroidPlatformAnnotations>$(AndroidSdkDirectory)/platforms/android-$(AndroidPlatformId)/data/annotations.zip</_AndroidPlatformAnnotations>
144+
<_PlatformToolsAnnotations>$(AndroidSdkDirectory)/platform-tools/api/annotations.zip</_PlatformToolsAnnotations>
145+
<_AnnotationsZip Condition=" Exists($(_AndroidPlatformAnnotations)) ">$(_AndroidPlatformAnnotation)</_AnnotationsZip>
146+
<_AnnotationsZip Condition=" '$(_AnnotationsZip)' == '' And Exists('$(_PlatformToolsAnnotations)') ">$(_PlatformToolsAnnotations)</_AnnotationsZip>
143147
</PropertyGroup>
144148
<ItemGroup>
145149
<_ApiVersion
@@ -160,7 +164,7 @@
160164
<_Fixup>--fixup=metadata</_Fixup>
161165
<_Enums1>--preserve-enums --enumflags=enumflags --enumfields=map.csv --enummethods=methodmap.csv</_Enums1>
162166
<_Enums2>--enummetadata=$(IntermediateOutputPath)mcw\enummetadata</_Enums2>
163-
<_Annotations>--annotations="$(AndroidSdkDirectory)/platform-tools/api/annotations.zip"</_Annotations>
167+
<_Annotations Condition=" '$(_AnnotationsZip)' != '' ">"--annotations=$(_AnnotationsZip)"</_Annotations>
164168
<_Assembly>--assembly="Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"</_Assembly>
165169
<_TypeMap>--type-map-report=$(IntermediateOutputPath)mcw\type-mapping.txt</_TypeMap>
166170
<_Api>$(IntermediateOutputPath)mcw\api.xml</_Api>

0 commit comments

Comments
 (0)