Fixed
Status Update
Comments
ja...@gmail.com <ja...@gmail.com> #2
This would also be useful for entire types. Like switching from `android.support.v4.util.SparseArray` to `android.util.SparseArray`. The problem there, though, is that you have to remember to update the annotation value if SparseArray gets updated to include new functionality from newer API levels. That's a developer problem though.
vs...@google.com <vs...@google.com>
ja...@gmail.com <ja...@gmail.com> #3
Would be great to steal ReplaceWith from Kotlin's @Deprecated as well, although that isn't needed for an initial version.
so...@gmail.com <so...@gmail.com> #4
I think @DeprecatedSdkVersion should accept an int array as there could be potentially more than one Deprecated Version.
ja...@gmail.com <ja...@gmail.com> #5
For what case? Either you're below the version and in which case the method is used or you're equal to or above it in which case it's not needed.
tn...@google.com <tn...@google.com> #6
This has now been implemented (the annotation name is @DeprecatedSinceApi).
- Annotations:
https://cs.android.com/androidx/platform/frameworks/support/+/21946a272d01be51efd6ee6559a5d3e94305ddb6 - Lint support:
https://cs.android.com/android-studio/platform/tools/base/+/802f71dd0728197acefb367e8d39f0af72ad1f5c
Thanks for the suggestion!
de...@google.com <de...@google.com> #7
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Dolphin Canary 2 (2021.3.1.2)
- Android Gradle Plugin 7.3.0-alpha02
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description
I propose adding a new annotation to support-annotations like @DeprecatedSdkVersion whose value property is an SDK_INT but also provides an optional details property for what method to use instead.
public @Interface DeprecatedSdkVersion {
int value();
String details = "";
}
Which can be used like this:
public final class ViewCompat {
@DeprecatedSdkVersion(Build.VERSION_CODES.LOLLIPOP)
public static int getElevation(View view) { ... }
@DeprecatedSdkVersion(
value = Build.VERSION_CODES.LOLLIPOP,
details = "Use view.getElevation() directly."
)
public static int getElevation(View view) { ... }
}
(Other potential names: @MaxSdkVersion, @UntilSdkVersion)
This would come with a corresponding lint check that would issue a warning if you were using one of these methods with a minSdkVersion higher than the annotation's value.