Status Update
Comments
ze...@google.com <ze...@google.com> #2
We're seeing a similar error in our code. Appears to be a combination of AGP 8.6.0 and Kotlin 2 needed to hit it.
private fun Intent.stripUnwantedFlags() {
// Explicitly remove the new task and clear task flags (Our browser activity is a single
// task activity and we never want to start a second task here).
flags = flags and Intent.FLAG_ACTIVITY_NEW_TASK.inv()
flags = flags and Intent.FLAG_ACTIVITY_CLEAR_TASK.inv()
// IntentReceiverActivity is started with the "excludeFromRecents" flag (set in manifest). We
// do not want to propagate this flag from the intent receiver activity to the browser.
flags = flags and Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS.inv()
}
All 3 lines then hit:
Must be one or more of: Intent.FLAG_GRANT_READ_URI_PERMISSION, Intent.FLAG_GRANT_WRITE_URI_PERMISSION, Intent.FLAG_FROM_BACKGROUND, Intent.FLAG_DEBUG_LOG_RESOLUTION, Intent.FLAG_EXCLUDE_STOPPED_PACKAGES, Intent.FLAG_INCLUDE_STOPPED_PACKAGES, Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION, Intent.FLAG_GRANT_PREFIX_URI_PERMISSION, Intent.FLAG_ACTIVITY_MATCH_EXTERNAL, Intent.FLAG_ACTIVITY_NO_HISTORY, Intent.FLAG_ACTIVITY_SINGLE_TOP, Intent.FLAG_ACTIVITY_NEW_TASK, Intent.FLAG_ACTIVITY_MULTIPLE_TASK, Intent.FLAG_ACTIVITY_CLEAR_TOP, Intent.FLAG_ACTIVITY_FORWARD_RESULT, Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP, Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT, Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, Intent.FLAG_ACTIVITY_NEW_DOCUMENT, Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, Intent.FLAG_ACTIVITY_NO_USER_ACTION, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT, Intent.FLAG_ACTIVITY_NO_ANIMATION, Intent.FLAG_ACTIVITY_CLEAR_TASK, Intent.FLAG_ACTIVITY_TASK_ON_HOME, Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS, Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT, Intent.FLAG_ACTIVITY_REQUIRE_NON_BROWSER, Intent.FLAG_ACTIVITY_REQUIRE_DEFAULT, Intent.FLAG_RECEIVER_REGISTERED_ONLY, Intent.FLAG_RECEIVER_REPLACE_PENDING, Intent.FLAG_RECEIVER_FOREGROUND, Intent.FLAG_RECEIVER_NO_ABORT, Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS
ja...@jamesonwilliams.com <ja...@jamesonwilliams.com> #3
The initial report (
However,
ze...@google.com <ze...@google.com> #4
Thanks for fixing! What release should we be able to verify the fix in? And is there any chance of a backport for 8.6.1?
cl...@google.com <cl...@google.com> #7
Thanks for the update!
ja...@jamesonwilliams.com <ja...@jamesonwilliams.com> #8
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 Ladybug Feature Drop | 2024.2.2 Canary 2
- Android Gradle Plugin 8.8.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!
cl...@google.com <cl...@google.com> #9
The fixes for this issue are now also available in:
- Android Studio Ladybug | 2024.2.1 RC 1
- Android Gradle Plugin 8.7.0-rc01
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
ja...@jamesonwilliams.com <ja...@jamesonwilliams.com> #10
Thanks! I agree the error message could be improved.
Per the title, my original report here is really a feature request: "Can you add support for ThreadLocal#withInitial(...)
into the desugaring library?"
I have also
cl...@google.com <cl...@google.com> #11
I will add ThreadLocal#withInitial to the desugared library wanted features hotlist, we'll see what we can do. It's not going to happen anytime soon though (at the very least not this quarter), so it's probably better if you build a work-around for now.
sg...@google.com <sg...@google.com> #12
Given a supplier
Supplier<T> supplier = ...
Could
ThreadLocal<T> threadLocal = ThreadLocal.withInitial(supplier)
be desugared to
class SynthesizedThreadLocalSubClass extends ThreadLocal<T> {
private Supplier<T> supplier;
SynthesizedThreadLocalSubClass(Supplier<T> supplier) {
this.supplier = supplier;
}
protected T initialValue() {
return supplier.get();
}
}
ThreadLocal<T> threadLocal = new SynthesizedThreadLocalSubClass(supplier);
?
That could allow this to be handled using backporting if backporting is extended to synthesize the subclass SynthesizedThreadLocalSubClass
of ThreadLocal
if required (that is if ThreadLocal.withInitial
is used in the app).
mi...@gmail.com <mi...@gmail.com> #13
Any update on this?
cl...@google.com <cl...@google.com> #14
We've not worked on implementing a work-around for ThreadLocal.withInitial() so far.
@sgjesse should we try this quarter/next quarter?
sg...@google.com <sg...@google.com>
ap...@google.com <ap...@google.com> #15
Branch: main
commit a6f2739d4969ce085b93529c7cd20cc4cfee176b
Author: Søren Gjesse <sgjesse@google.com>
Date: Thu Sep 08 16:10:10 2022
Backport ThreadLocal.withInitial when Supplier is present
This will backport ThreadLocal.withInitial(java.util.function.Supplier)
when java.util.function.Supplier is present at runtime.
Without desugared library this makes the method usable from API level
24 (when Supplier was introduced) instead of from API level 26 (when
withInitial was introduced).
With desugared library the method is always usable as Supplier is
included in all desugared library versions.
Bug:
Change-Id: I536879372d903d15b182a2ef071adf01361c8f01
M src/main/java/com/android/tools/r8/graph/DexItemFactory.java
M src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
M src/main/java/com/android/tools/r8/ir/desugar/backports/BackportedMethodDesugaringEventConsumer.java
M src/main/java/com/android/tools/r8/ir/desugar/CfInstructionDesugaringEventConsumer.java
A src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportWithDesugaredLibraryTest.java
M src/main/java/com/android/tools/r8/synthesis/SyntheticNaming.java
A src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportTest.java
ap...@google.com <ap...@google.com> #16
Branch: main
commit b595f9b29de6e925a1a8e82f02a74a6d0da4db2c
Author: Søren Gjesse <sgjesse@google.com>
Date: Tue Sep 13 12:49:15 2022
Fix stack height for rewrite or ThreadLocal.withInitial
Bug:
Change-Id: I89d10b9d45357b57d32db47737035f38a5cb27f8
M src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
M src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportTest.java
ap...@google.com <ap...@google.com> #17
Branch: 3.2
commit 65092faa0276ccb00a37b8d35a10038cbbdec5fb
Author: Søren Gjesse <sgjesse@google.com>
Date: Wed Sep 14 11:08:57 2022
Version 3.2.81
Contains changes to resolve cherry-pick issues.
Bug:
Change-Id: I95cf2b7ef6dd6a7eafbff2a4735c7cd6d60f35de
M src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
M src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportWithDesugaredLibraryTest.java
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #18
Branch: 3.2
commit 703819c5fa4cff78373dee829761f807574ec2b9
Author: Søren Gjesse <sgjesse@google.com>
Date: Wed Sep 14 11:07:00 2022
Fix stack height for rewrite or ThreadLocal.withInitial
Bug:
Change-Id: I89d10b9d45357b57d32db47737035f38a5cb27f8
M src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
M src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportTest.java
ap...@google.com <ap...@google.com> #19
Branch: 3.2
commit 3931c5a1299bf1c2df1bfae06a9b954d2dc87b52
Author: Søren Gjesse <sgjesse@google.com>
Date: Wed Sep 14 11:06:28 2022
Backport ThreadLocal.withInitial when Supplier is present
This will backport ThreadLocal.withInitial(java.util.function.Supplier)
when java.util.function.Supplier is present at runtime.
Without desugared library this makes the method usable from API level
24 (when Supplier was introduced) instead of from API level 26 (when
withInitial was introduced).
With desugared library the method is always usable as Supplier is
included in all desugared library versions.
Bug:
Change-Id: I536879372d903d15b182a2ef071adf01361c8f01
M src/main/java/com/android/tools/r8/graph/DexItemFactory.java
M src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
M src/main/java/com/android/tools/r8/ir/desugar/backports/BackportedMethodDesugaringEventConsumer.java
M src/main/java/com/android/tools/r8/ir/desugar/CfInstructionDesugaringEventConsumer.java
A src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportWithDesugaredLibraryTest.java
M src/main/java/com/android/tools/r8/synthesis/SyntheticNaming.java
A src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportTest.java
sg...@google.com <sg...@google.com>
sg...@google.com <sg...@google.com>
ap...@google.com <ap...@google.com> #20
Branch: 4.0
commit 3b4722724a1460a5f0a245089210bf4e42cada23
Author: Søren Gjesse <sgjesse@google.com>
Date: Wed Sep 14 13:02:41 2022
Version 4.0.29
Bug:
Change-Id: I66dd4552b850077b8abfa87fb2760d7b17cdde62
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #21
Branch: 4.0
commit 654dcebcc75dbfa59b40ded2f5b1e87195af94a2
Author: Søren Gjesse <sgjesse@google.com>
Date: Wed Sep 14 13:02:32 2022
Fix stack height for rewrite or ThreadLocal.withInitial
Bug:
Change-Id: I89d10b9d45357b57d32db47737035f38a5cb27f8
M src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
M src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportTest.java
ap...@google.com <ap...@google.com> #22
Branch: 4.0
commit edf6432389f51e54f165a04fe32b0522e92306ad
Author: Søren Gjesse <sgjesse@google.com>
Date: Wed Sep 14 12:57:52 2022
Backport ThreadLocal.withInitial when Supplier is present
This will backport ThreadLocal.withInitial(java.util.function.Supplier)
when java.util.function.Supplier is present at runtime.
Without desugared library this makes the method usable from API level
24 (when Supplier was introduced) instead of from API level 26 (when
withInitial was introduced).
With desugared library the method is always usable as Supplier is
included in all desugared library versions.
Bug:
Change-Id: I536879372d903d15b182a2ef071adf01361c8f01
M src/main/java/com/android/tools/r8/graph/DexItemFactory.java
M src/main/java/com/android/tools/r8/ir/desugar/backports/BackportedMethodDesugaringEventConsumer.java
M src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
M src/main/java/com/android/tools/r8/ir/desugar/CfInstructionDesugaringEventConsumer.java
A src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportWithDesugaredLibraryTest.java
M src/main/java/com/android/tools/r8/synthesis/SyntheticNaming.java
A src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportTest.java
ap...@google.com <ap...@google.com> #23
Branch: 3.3
commit d6e7e48c4ae98e002e962c070f5dd310c85a59e0
Author: Søren Gjesse <sgjesse@google.com>
Date: Wed Sep 14 12:36:52 2022
Version 3.3.79
Contains changes to resolve cherry-pick issues.
Bug:
Change-Id: I65e2242cdf294aabc03dd728e63c68cea653c92a
M src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportWithDesugaredLibraryTest.java
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #24
Branch: 3.3
commit a9d35293e7c3e9bd7544dadc1aa3afac6829ec23
Author: Søren Gjesse <sgjesse@google.com>
Date: Wed Sep 14 12:36:33 2022
Fix stack height for rewrite or ThreadLocal.withInitial
Bug:
Change-Id: I89d10b9d45357b57d32db47737035f38a5cb27f8
M src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
M src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportTest.java
ap...@google.com <ap...@google.com> #25
Branch: 3.3
commit c460eb8a5ba603d8833d02d78b92321416ae78ae
Author: Søren Gjesse <sgjesse@google.com>
Date: Wed Sep 14 12:35:53 2022
Backport ThreadLocal.withInitial when Supplier is present
This will backport ThreadLocal.withInitial(java.util.function.Supplier)
when java.util.function.Supplier is present at runtime.
Without desugared library this makes the method usable from API level
24 (when Supplier was introduced) instead of from API level 26 (when
withInitial was introduced).
With desugared library the method is always usable as Supplier is
included in all desugared library versions.
Bug:
Change-Id: I536879372d903d15b182a2ef071adf01361c8f01
M src/main/java/com/android/tools/r8/graph/DexItemFactory.java
M src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
M src/main/java/com/android/tools/r8/ir/desugar/backports/BackportedMethodDesugaringEventConsumer.java
M src/main/java/com/android/tools/r8/ir/desugar/CfInstructionDesugaringEventConsumer.java
A src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportWithDesugaredLibraryTest.java
A src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportTest.java
M src/main/java/com/android/tools/r8/synthesis/SyntheticNaming.java
ap...@google.com <ap...@google.com> #26
Branch: 4.0
commit 654dcebcc75dbfa59b40ded2f5b1e87195af94a2
Author: Søren Gjesse <sgjesse@google.com>
Date: Wed Sep 14 13:02:32 2022
Fix stack height for rewrite or ThreadLocal.withInitial
Bug:
Change-Id: I89d10b9d45357b57d32db47737035f38a5cb27f8
M src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
M src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportTest.java
ap...@google.com <ap...@google.com> #27
Branch: 4.0
commit edf6432389f51e54f165a04fe32b0522e92306ad
Author: Søren Gjesse <sgjesse@google.com>
Date: Wed Sep 14 12:57:52 2022
Backport ThreadLocal.withInitial when Supplier is present
This will backport ThreadLocal.withInitial(java.util.function.Supplier)
when java.util.function.Supplier is present at runtime.
Without desugared library this makes the method usable from API level
24 (when Supplier was introduced) instead of from API level 26 (when
withInitial was introduced).
With desugared library the method is always usable as Supplier is
included in all desugared library versions.
Bug:
Change-Id: I536879372d903d15b182a2ef071adf01361c8f01
M src/main/java/com/android/tools/r8/graph/DexItemFactory.java
M src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
M src/main/java/com/android/tools/r8/ir/desugar/backports/BackportedMethodDesugaringEventConsumer.java
M src/main/java/com/android/tools/r8/ir/desugar/CfInstructionDesugaringEventConsumer.java
A src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportWithDesugaredLibraryTest.java
M src/main/java/com/android/tools/r8/synthesis/SyntheticNaming.java
A src/test/java/com/android/tools/r8/desugar/backports/ThreadLocalBackportTest.java
Description
What I'm Doing
I am trying to use core library desugaring with Android Studio 4.0.0. I use AGP 4.0.0, Gradle 6.5.1.
I am using an Android 5 (API 21) device.
I have:
And:
I include some simple code:
What Goes Wrong
This will build, and install. But, at runtime, on the API 21 device, the application crashes:
Why It Goes Wrong (Maybe)
The line it is unhappy about is in
ThreadLocal
'swithInitial
static method, which takes ajava.util.function.Supplier
.ThreadLocal
is NOT listed in theAdditional Information
The build did include copious warnings.
Expected Behavior
Desugaring tools produce working implementation for
ThreadLocal.withInitial(Supplier)
. The code functions on an Android 5 / API 21 device.