You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)Β #7769
The latest version of Guava uses MethodHandle which is only available in Android API 26 or later. My app supports API 21 at the minimum, and it uses the latest release of Guava to patch a security vulnerability, only now it won't build because Guava uses methods that are not supported in the minimum SDK version. And I have no desire to increase it in my app.
Example
AnyAndroidappwithminimumSDKversionlowerthan26, usingthelatestversionofGuava, wouldsuffice. Here's a PR build from my repo that failed:
https://github.com/JordanLongstaff/ArtemisAgent/actions/runs/14347309233/job/40219434611?pr=189
Expected Behavior
App should still build as normal.
Actual Behavior
App cannot build because of MethodHandle. See the link in the example for more info.
Sorry, our internal toolchain must handle things differently, as we're able to build for minSdkVersion 21 there. (We should ideally set up an external test for this.) Thanks for the fast report of this. I'll look when I start work in an hour or two.
* What went wrong:
A problem occurred configuring project ':IAN:annotations:konsist'.
> Failed to apply plugin 'org.gradle.software-reporting-tasks'.
> Could not create task ':IAN:annotations:konsist:outgoingVariants'.
> Could not create task of type 'OutgoingVariantsReportTask'.
> Could not create an instance of type org.gradle.api.tasks.diagnostics.internal.configurations.ConfigurationReportsImpl.
> Could not create an instance of type org.gradle.api.reporting.internal.DefaultReportContainer.
> Type T not present
[edit: This might have been a problem running with JDK 24, specifically in combination with Kotlin (rather than Groovy)?]
But a search got me to a PR for another Android app, which also has the problem, as you'd pointed out. I can reproduce the problem there with JAVA_HOME=$HOME/.m2/jdks/jdk-17.0.13+11 ANDROID_HOME=$HOME/android-sdk-linux ./gradlew build, so I'll iterate with that.
As for what I'll do about this: I might just forget about using VarHandle from guava-android, instead making the code try AtomicReferenceFieldUpdater before Unsafe on the JVM. But I'll see what else I can figure out....
I have to run my change through some further testing (both in our monorepo and against one of the AGP projects), but I expect to be able to submit it later today and hopefully even get a new release out soon after.
My testing against the AGP project suggests that the fix works, and I've gotten the internal code review that I need for submission. I am still waiting for the internal testing, which won't be done for at least a few hours more. Still, barring surprises, I should be able to publish a release with the fix early in my work day tomorrow.
There's been some trouble with the internal testing system, which has affected my multiple attempts to test my change yesterday. The owners of the system have been looking into it. I assume that it will get resolved enough that I can submit my change on Monday.
Activity
cpovirk commentedon Apr 9, 2025
Sorry, our internal toolchain must handle things differently, as we're able to build for minSdkVersion 21 there. (We should ideally set up an external test for this.) Thanks for the fast report of this. I'll look when I start work in an hour or two.
cpovirk commentedon Apr 9, 2025
I haven't gotten the build running locally yet, though I made a little progress:
So:
But now:
[edit: This might have been a problem running with JDK 24, specifically in combination with Kotlin (rather than Groovy)?]
But a search got me to a PR for another Android app, which also has the problem, as you'd pointed out. I can reproduce the problem there with
JAVA_HOME=$HOME/.m2/jdks/jdk-17.0.13+11 ANDROID_HOME=$HOME/android-sdk-linux ./gradlew build, so I'll iterate with that.As for what I'll do about this: I might just forget about using
VarHandlefromguava-android, instead making the code tryAtomicReferenceFieldUpdaterbeforeUnsafeon the JVM. But I'll see what else I can figure out....cpovirk commentedon Apr 9, 2025
Hmm, maybe this is only an issue before AGP 7.4: http://issuetracker.google.com/issues/174733673#comment12?
But no, the app I'm testing with is using 8.3.1: https://github.com/mathisdt/trackworktime/blob/7f38ecc8c0b1f0eb396fec94b47e1ca0cae6b085/build.gradle#L9.
http://issuetracker.google.com/issues/174733673#comment13 suggests that the issue is fixed at the compiler level but needs a change in the plugin itself: http://issuetracker.google.com/issues/320207221.
Use `AtomicReferenceFieldUpdater` instead of `VarHandle` when `guava-β¦
cpovirk commentedon Apr 9, 2025
I have to run my change through some further testing (both in our monorepo and against one of the AGP projects), but I expect to be able to submit it later today and hopefully even get a new release out soon after.
Use `AtomicReferenceFieldUpdater` instead of `VarHandle` when `guava-β¦
cpovirk commentedon Apr 9, 2025
My testing against the AGP project suggests that the fix works, and I've gotten the internal code review that I need for submission. I am still waiting for the internal testing, which won't be done for at least a few hours more. Still, barring surprises, I should be able to publish a release with the fix early in my work day tomorrow.
cpovirk commentedon Apr 10, 2025
There's been some trouble with the internal testing system, which has affected my multiple attempts to test my change yesterday. The owners of the system have been looking into it. I assume that it will get resolved enough that I can submit my change on Monday.
DO NOT MERGE: AGP integration test.
DO NOT MERGE: AGP integration test.
JordanLongstaff commentedon Apr 12, 2025
@cpovirk Just wanted to say, I greatly appreciate your efforts and your transparency in trying to fix this. π
Use `AtomicReferenceFieldUpdater` instead of `VarHandle` when `guava-β¦
Use `AtomicReferenceFieldUpdater` instead of `VarHandle` when `guava-β¦
cpovirk commentedon Apr 14, 2025
I published Guava 33.4.8 (release notes, Maven Central) with the fix. May this be the conclusion to the last problem with this series of releases :)