I have read the dozens of questions here on SO regarding recycling TypedArrays, but I guess they are a bit too old and written before we could widely use try-with-resource statements, so none of them talk about using the AutoCloseable implementation of the TypedArray, which is present since API Level 31
So the question remains: is this a false positive in Lint?

If anything, that warning should be a minSDK warning if applicable, right? Can we simply write the following since the full try-with support (if we do it after SDK Level >= 31 check)?
try (TypedArray array = getContext().obtainStyledAttributes(attrs) {
// Do someting
}
// End of method
My guess is yes, as this is the AutoCloseable implementation of TypedArray

No, it is not. Because
closemethod inAutoCloseableinterface is not magically called when using try/catch.Instead you have to use
usemethod and then and only then you can get rid of try/catch like following:But, be aware that
usemethod fromTypedArrayclass is available only since Android 31If you prefer a backwards compatible solution, you can use
usemethod fromandroidx.core:core-ktxlibrary.As
TypedArrayalso provides of ausemethod you will have to take care of adding the following import: