Skip to content

Commit 743f27e

Browse files
AndroidX Core Teamcopybara-github
AndroidX Core Team
authored andcommittedMay 5, 2023
More specific guidance around BuildCompat checks
PiperOrigin-RevId: 529735932 Change-Id: I050ff834fc5ed4facf38be11fd8eb295061c0dec
1 parent dae522b commit 743f27e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed
 

‎docs/api_guidelines/compat.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ private object Api29Impl {
5656
```
5757

5858
When developing against pre-release SDKs where the `SDK_INT` has not been
59-
finalized, SDK checks **must** use `BuildCompat.isAtLeastX()` methods.
59+
finalized, SDK checks **must** use `BuildCompat.isAtLeastX()` methods and
60+
**must** use a tip-of-tree `project` dependency to ensure that the
61+
implementation of `BuildCompat` stays up-to-date when the SDK is finalized.
62+
63+
**Do not** assume that the next SDK release's `SDK_INT` will be N+1. The value
64+
is not finalized until SDK finalization happens, at which point the `isAtLeast`
65+
check will be updated. **Never** write your own check for a pre-release SDK.
6066

6167
```java {.good}
6268
@NonNull
@@ -68,6 +74,12 @@ public static List<Window> getAllWindows() {
6874
}
6975
```
7076

77+
```kotlin {.good}
78+
dependencies {
79+
api(project(":core:core"))
80+
}
81+
```
82+
7183
##### Preventing invalid casting {#compat-casting}
7284

7385
Even when a call to a new API is moved to a version-specific class, a class

0 commit comments

Comments
 (0)