Skip to content

Commit 2cace0b

Browse files
atsushienojonpryor
authored andcommitted
[Mono.Android] Add Android API-Q preview binding (#2829)
Context: https://developer.android.com/preview/overview [^1] Android Q Beta 1 has been released. The API-Q Program Overview [Timeline and updates][0] section suggests the following: * Beta 2 in early April * Beta 3 in early May * Beta 4 in early June. This contains the final APIs and official SDK. * Beta 5, 6, and final release sometime in Q3, 2019. Add support for binding API-Q as API-29, with `$(TargetFrameworkVersion)` v9.0.99. Note: The Android SDK **Build-tools** package version 29-rc1 appears to be busted, in that `apksigner.jar` generates invalid `.apk` files. Our [PR build][1] had errors attempting to install `.apk` files: AndroidApkSigner: ApkSignerJar: …/android-toolchain/sdk/build-tools/29.0.0-rc1/lib/apksigner.jar ApkToSign: …/bin/TestRelease/Xamarin.Android.Locale_Tests-Signed.apk ManifestFile: obj/Release/android/AndroidManifest.xml AdditionalArguments: java -jar …/android-toolchain/sdk/build-tools/29.0.0-rc1/lib/apksigner.jar sign --ks "…/.local/share/Xamarin/Mono for Android/debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 16 --max-sdk-version 22 …/bin/TestRelease/Xamarin.Android.Locale_Tests-Signed.apk ... Executing: …/android-toolchain/sdk/platform-tools/adb -s emulator-5570 install "…/bin/TestRelease/Xamarin.Android.Locale_Tests-Signed.apk" …/build-tools/scripts/TestApks.targets(154,5): warning : adb: failed to install …/bin/TestRelease/Xamarin.Android.Locale_Tests-Signed.apk: Failure [INSTALL_PARSE_FAILED_NOT_APK: Failed to parse /data/app/vmdl242845261.tmp/base.apk] Finally, remove `Animation` events from set~ method only after Q API. Without this change, there was API compatibility breakage: <h3>Type Changed: Android.Views.Animations.Animation</h3> <p>Removed events:</p> <pre> <span class='removed removed-event breaking' data-is-breaking>public event System.EventHandler&lt;Animation.AnimationEndEventArgs&gt; AnimationEnd;</span> <span class='removed removed-event breaking' data-is-breaking>public event System.EventHandler&lt;Animation.AnimationRepeatEventArgs&gt; AnimationRepeat;</span> <span class='removed removed-event breaking' data-is-breaking>public event System.EventHandler&lt;Animation.AnimationStartEventArgs&gt; AnimationStart;</span> </pre> [0]: https://developer.android.com/preview/overview#timeline [1]: https://jenkins.mono-project.com/job/xamarin-android-pr-pipeline-release/151/ [^1]: No `archive.org` URL because one doesn't exist yet. :-(
1 parent f098d9c commit 2cace0b

File tree

10 files changed

+31793
-10
lines changed

10 files changed

+31793
-10
lines changed

Configuration.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
<AndroidLatestStablePlatformId Condition="'$(AndroidLatestStablePlatformId)' == ''">$(AndroidLatestStableApiLevel)</AndroidLatestStablePlatformId>
2727
<AndroidLatestStableFrameworkVersion Condition="'$(AndroidLatestStableFrameworkVersion)'==''">v9.0</AndroidLatestStableFrameworkVersion>
2828
<!-- *Latest* (possibly unstable) API level binding that we support; for informational purposes -->
29-
<AndroidLatestApiLevel Condition="'$(AndroidLatestApiLevel)' == ''">28</AndroidLatestApiLevel>
30-
<AndroidLatestPlatformId Condition=" '$(AndroidLatestPlatformId)' == '' ">28</AndroidLatestPlatformId>
31-
<AndroidLatestFrameworkVersion Condition="'$(AndroidLatestFrameworkVersion)' == ''">v9.0</AndroidLatestFrameworkVersion>
29+
<AndroidLatestApiLevel Condition="'$(AndroidLatestApiLevel)' == ''">29</AndroidLatestApiLevel>
30+
<AndroidLatestPlatformId Condition=" '$(AndroidLatestPlatformId)' == '' ">Q</AndroidLatestPlatformId>
31+
<AndroidLatestFrameworkVersion Condition="'$(AndroidLatestFrameworkVersion)' == ''">v9.0.99</AndroidLatestFrameworkVersion>
3232
<!-- The API level and TargetFrameworkVersion for the default Mono.Android.dll build -->
3333
<AndroidApiLevel Condition=" '$(AndroidApiLevel)' == '' ">$(AndroidLatestStableApiLevel)</AndroidApiLevel>
3434
<AndroidPlatformId Condition=" '$(AndroidPlatformId)' == '' ">$(AndroidLatestStablePlatformId)</AndroidPlatformId>

Documentation/workflow/HowToAddNewApiLevel.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11

22
# How to deal with new API Level
33

4+
5+
## Quick Android Q API support workflow logs.
6+
7+
- Make changes to Configuration.props
8+
- Add android-toolchain projitems
9+
- Run `make prepare` and `make` to first download platform-Q under `~/android-toolchain`
10+
- Generate android-Q.params.txt
11+
- go to `external/Java.Interop/build-tools/xamarin-android-docimporter-ng`.
12+
- add new API level to `generate.sh`
13+
- run `nuget restore`, `make`, and `./generate.sh`. Take some rest (it takes a while).
14+
- copy `android-*.params.txt` to `{xamarin-android topdir}/src/Mono.Android/Profiles/`.
15+
- In `src/Mono.Android/Profiles/`, renamed `android-Q.params.txt` to `android-29.params.txt` as the later builds expect that.
16+
- Make changes to `Configuration.props`, create `Configuration.Override.props` to set AndroidApiLevel etc.
17+
- Make other changes to e.g. `build-tools/scripts/BuildEverything.mk`, `src/Mono.Android/Mono.Android.projitems`.
18+
- run `make` on xamarin-android topdir. It results in various errors.
19+
- Fix builds by making changes to `src/Mono.Android/metadata` and sources under `src/Mono.Android`.
20+
421
## This documentation is incomplete
522

623
In Xamarin ages, we used to have (more complete) API upgrade guide internally. But since then we switched to new xamarin-android repository which entirely changed the build system from Makefile to MSBuild solution, as well as the managed API for manipulating Android SDK, the old documentation almost does not make sense anymore. Even though I am writing this documentation, I don't know everything required (nor those who changed the build system didn't care about API upgrades).

build-tools/android-toolchain/android-toolchain.projitems

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@
143143
<HostOS></HostOS>
144144
<DestDir>platforms\android-28</DestDir>
145145
</AndroidSdkItem>
146+
<AndroidSdkItem Include="platform-Q_r01">
147+
<HostOS></HostOS>
148+
<DestDir>platforms\android-Q</DestDir>
149+
</AndroidSdkItem>
146150
<AndroidSdkItem Include="docs-24_r01">
147151
<HostOS></HostOS>
148152
<DestDir>docs</DestDir>

build-tools/api-xml-adjuster/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ API_XML_TOOL = $(BUILDBIN)/api-xml-adjuster.exe
1717
RUNTIME = mono --debug
1818
RUN_CLASS_PARSE = $(RUNTIME) $(CLASS_PARSE)
1919
RUN_API_XML_TOOL = $(RUNTIME) $(API_XML_TOOL)
20-
API_LEVELS = 10 15 16 17 18 19 20 21 22 23 24 25 26 27 28
20+
API_LEVELS = 10 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Q
2121

2222
XML_OUTPUT_DIR = .
2323

build-tools/scripts/BuildEverything.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ ZIP_OUTPUT = $(ZIP_OUTPUT_BASENAME).$(ZIP_EXTENSION)
2323
## The following values *must* use SPACE, **not** TAB, to separate values.
2424

2525
# $(ALL_API_LEVELS) and $(ALL_FRAMEWORKS) must be kept in sync w/ each other
26-
ALL_API_LEVELS = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
26+
ALL_API_LEVELS = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
2727
# this was different from ALL_API_LEVELS when API Level 26 was "O". Same could happen in the future.
28-
ALL_PLATFORM_IDS = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
28+
ALL_PLATFORM_IDS = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Q
2929
# supported api levels
30-
ALL_FRAMEWORKS = _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ v4.4 v4.4.87 v5.0 v5.1 v6.0 v7.0 v7.1 v8.0 v8.1 v9.0
31-
API_LEVELS = 19 20 21 22 23 24 25 26 27 28
30+
ALL_FRAMEWORKS = _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ v4.4 v4.4.87 v5.0 v5.1 v6.0 v7.0 v7.1 v8.0 v8.1 v9.0 v9.0.99
31+
API_LEVELS = 19 20 21 22 23 24 25 26 27 28 29
3232
STABLE_API_LEVELS = 19 20 21 22 23 24 25 26 27 28
3333

3434
## The preceding values *must* use SPACE, **not** TAB, to separate values.

src/Mono.Android/Java.Lang/StringBuffer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// It is introduced since API 26 not because of new member in StringBuffer
44
// but in AbstractStringBuilder which is nonpublic and affects the generated API.
55

6+
#if !ANDROID_29
7+
// However, AbstractStringBuilder has changed in Android Q and it does not seem to be required anymore (this rather blocks build).
8+
69
using System;
710

811
namespace Java.Lang
@@ -17,3 +20,4 @@ public IAppendable Append (string s, int start, int end)
1720
}
1821

1922
#endif
23+
#endif

src/Mono.Android/Java.Lang/StringBuilder.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// It is introduced since API 26 not because of new member in StringBuffer
44
// but in AbstractStringBuilder which is nonpublic and affects the generated API.
55

6+
#if !ANDROID_29
7+
// However, AbstractStringBuilder has changed in Android Q and it does not seem to be required anymore (this rather blocks build).
8+
69
using System;
710

811
namespace Java.Lang
@@ -17,3 +20,4 @@ public IAppendable Append (string s, int start, int end)
1720
}
1821

1922
#endif
23+
#endif

src/Mono.Android/Mono.Android.projitems

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@
145145
<Id>28</Id>
146146
<Stable>True</Stable>
147147
</AndroidApiInfo>
148+
<AndroidApiInfo Include="v9.0.99">
149+
<Name>Q</Name>
150+
<Level>29</Level>
151+
<Id>Q</Id>
152+
<Stable>False</Stable>
153+
</AndroidApiInfo>
148154
</ItemGroup>
149155

150156
</Project>

0 commit comments

Comments
 (0)