Status Update
Comments
ap...@google.com <ap...@google.com> #2
EDIT: meant TypedArray#recycle
and not TypedArray#release
ap...@google.com <ap...@google.com> #3
Lint should show a warning in this case, as implements AutoClosable
and the use of TypedArray#close()
require API level 31. Consequently the IDE should also not suggest the refactor to try with resources unless minSdk
is at least 31.
Maybe the issue is that api-versions.xml
(from platforms/android-33/data/api-versions.xml
) only mention implements AutoClosable
, and not the close()
method
<class name="android/content/res/TypedArray" since="1">
<extends name="java/lang/Object"/>
<implements name="java/lang/AutoCloseable" since="31"/>
<method name="getBoolean(IZ)Z"/>
<method name="getChangingConfigurations()I" since="21"/>
<method name="getColor(II)I"/>
<method name="getColorStateList(I)Landroid/content/res/ColorStateList;"/>
<method name="getDimension(IF)F"/>
<method name="getDimensionPixelOffset(II)I"/>
<method name="getDimensionPixelSize(II)I"/>
<method name="getDrawable(I)Landroid/graphics/drawable/Drawable;"/>
<method name="getFloat(IF)F"/>
<method name="getFont(I)Landroid/graphics/Typeface;" since="26"/>
<method name="getFraction(IIIF)F"/>
<method name="getIndex(I)I"/>
<method name="getIndexCount()I"/>
<method name="getInt(II)I"/>
<method name="getInteger(II)I"/>
<method name="getLayoutDimension(II)I" since="3"/>
<method name="getLayoutDimension(ILjava/lang/String;)I"/>
<method name="getNonResourceString(I)Ljava/lang/String;"/>
<method name="getPositionDescription()Ljava/lang/String;"/>
<method name="getResourceId(II)I"/>
<method name="getResources()Landroid/content/res/Resources;"/>
<method name="getSourceResourceId(II)I" since="29"/>
<method name="getString(I)Ljava/lang/String;"/>
<method name="getText(I)Ljava/lang/CharSequence;"/>
<method name="getTextArray(I)[Ljava/lang/CharSequence;"/>
<method name="getType(I)I" since="21"/>
<method name="getValue(ILandroid/util/TypedValue;)Z"/>
<method name="hasValue(I)Z"/>
<method name="hasValueOrEmpty(I)Z" since="22"/>
<method name="length()I"/>
<method name="peekValue(I)Landroid/util/TypedValue;"/>
<method name="recycle()V"/>
</class>
Opened TypedArray#close()
to TypedArray#recycle()
, to make try with resources for TypedArray
supported on all API levels.
mk...@google.com <mk...@google.com> #4
Checked api-versions.xml
for more occurrences where implements AutoCloseable
was added together with a close
method after 19 where AutoCloseable
was introduced, and found
<class name="android/content/ContentProviderClient" since="5">
<extends name="java/lang/Object"/>
<implements name="java/lang/AutoCloseable" since="24"/>
close
also added in 24, as an alias for release
.
<class name="android/drm/DrmManagerClient" since="11" deprecated="30">
<extends name="java/lang/Object"/>
<implements name="java/lang/AutoCloseable" since="24"/>
close
also added in 24, as an alias for release
.
<class name="android/media/MediaDrm" since="18">
<extends name="java/lang/Object"/>
<implements name="java/lang/AutoCloseable" since="28"/>
close
also added in 28, as an alias for release
.
<class name="android/media/MediaMetadataRetriever" since="10">
<extends name="java/lang/Object"/>
<implements name="java/lang/AutoCloseable" since="29"/>
close
also added in 29, as an alias for release
.
<class name="android/net/wifi/p2p/WifiP2pManager$Channel" since="14">
<extends name="java/lang/Object"/>
<implements name="java/lang/AutoCloseable" since="27"/>
close
also added in 27, but not as an alias, as there was no similar method before (actually close
is the only method).
Opened
ap...@google.com <ap...@google.com> #5
I forgot to mark this bug when this was fixed last week, by this CL:
It's fixed in Giraffe/8.1 but I think we should backport it to Flamingo/8.0 as well.
Søren, it sounds like you want to start desugaring these methods (good idea); maybe there should be a different tracking issue for that.
ap...@google.com <ap...@google.com> #6
Thanks Tor. I have
ap...@google.com <ap...@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 Giraffe Canary 1 (2022.3.1.1)
- Android Gradle Plugin 8.1.0
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!
ap...@google.com <ap...@google.com> #8
Branch: main
commit 4ff176f892492b8bbb1a647f83cc0a9e679b40d9
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Thu Jan 26 09:58:05 2023
[Metadata] Move away from deprecated metadata visitors
Bug:
Change-Id: I3cd8f4b0a78ef6bfe9d9c38e2629b89315d0c9d1
D src/main/java/com/android/tools/r8/kotlin/KmVisitorProviders.java
M src/main/java/com/android/tools/r8/kotlin/KotlinAnnotationInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinClassInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinConstructorInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinContractInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinDeclarationContainerInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinEffectExpressionInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinEffectInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinFlexibleTypeUpperBoundInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinFunctionInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinJvmMethodSignatureInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinLambdaInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinLocalDelegatedPropertyInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinMetadataUtils.java
M src/main/java/com/android/tools/r8/kotlin/KotlinPackageInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinPropertyInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinSyntheticClassInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinTypeAliasInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinTypeInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinTypeParameterInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinTypeProjectionInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinValueParameterInfo.java
M src/main/java/com/android/tools/r8/kotlin/KotlinVersionRequirementInfo.java
Description