Status Update
Comments
sg...@google.com <sg...@google.com> #2
The backporting in the blocking bugs has been implemented and is part of R8 8.1.34-dev landing in Studio with
However, Lint still adds red squiggles in code like this:
try (TypedArray typedArray = resources.obtainTypedArray(R.array.colors)) {
System.out.println("Got TypedArray with " + typedArray.length() + " elements.");
}
I have checked, and the generated backported methods list (that lint gets from AGP) contains the following line:
android/content/res/TypedArray#close()V
For Kotlin, with use
resources.obtainTypedArray(R.array.colors).use { it -> "Got TypedArray with ${it.length()} elements." }
Here lint does not add any red squiggles neither with or without the backport. However, the backport does not currently work with use
. This is tracked in
The attached project has a TypedArray
and JavaTryWithResources.java
and KotlinUse.kt
using it.
ny...@gmail.com <ny...@gmail.com> #3
tn...@google.com <tn...@google.com> #4
Yep, this is now fixed in lint for the next canary. (Change-Id: Ife13e93be081e222def613aa641173bb9ad262f2)
an...@google.com <an...@google.com> #5
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 Koala | 2023.3.2 Canary 2
- Android Gradle Plugin 8.5.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
Some classes in the Android API have had
implements AutoCloseable
added together with aclose()
method at some API level after the class was introduced. When try with resources is used javac will generate code to call theclose()
method. This code will not work on API levels from before theclose()
method was introduced.When the
close()
method is an alias for a method which already existed, then the D8 backporting should rewrite theclose()
invoke to invoke the alias.This is a tracking bug with blocking bugs for the classes found in
api-versions.xml
for API level 33.