Status Update
Comments
am...@google.com <am...@google.com>
tn...@google.com <tn...@google.com> #2
Fix (pending) is I2c2dc7b600603ee430fd0d91b23d52ea8aa29ca9.
tn...@google.com <tn...@google.com> #3
tn...@google.com <tn...@google.com> #4
#sdkmanager --package_file=${PATH_WORKSPACE}/packages
while read p; do echo "y" | sdkmanager "${p}"; done <${PATH_WORKSPACE}/packages
tn...@google.com <tn...@google.com> #5
to...@yahoo.com <to...@yahoo.com> #6
tn...@google.com <tn...@google.com> #7
to...@yahoo.com <to...@yahoo.com> #8
tn...@google.com <tn...@google.com> #9
to...@yahoo.com <to...@yahoo.com> #10
```
(15:58:11) C02W513SHTD8:files aso$ /opt/android-sdk-macosx/tools/bin/sdkmanager --version
26.1.1
(15:58:17) C02W513SHTD8:files aso$ /opt/android-sdk-macosx/tools/bin/sdkmanager --install --package_file=package_file
Warning: Unknown argument --package_file=package_file
```
sg...@google.com <sg...@google.com> #11
tn...@google.com <tn...@google.com> #12
tn...@google.com <tn...@google.com> #13
to...@yahoo.com <to...@yahoo.com> #14
gh...@google.com <gh...@google.com> #15
sg...@google.com <sg...@google.com> #16
Has anyone re-tried it?
We switched back to RUN sdkmanager --package_file=$ANDROID_HOME/packages.txt
in our Dockerfile back in March of 2021.
sg...@google.com <sg...@google.com> #17
For what it's worth, I did a quick test with the latest CLI: 11076708 (
./sdkmanager --sdk_root="../sdk" --package_file=deps.txt
Deps.txt:
platform-tools
extras;google;instantapps
build-tools;35.0.0-rc3
So perhaps this is now resolved? I haven't tried it with more packages
to...@yahoo.com <to...@yahoo.com> #18
not as far as I'm concerned - this is a warning only which I can just ignore. The app compiles and works perfectly fine.
Methinks you guys have more important P1's to fix. If you need inspiration, then look at #127100532 (not related to this one at all, I'm just being ... now)
tn...@google.com <tn...@google.com> #19
I think I found the problem.
Here's the desugaring files used in the IDE:
modelArtifact?.desugaredMethodsFiles = {ArrayList@83951} size = 2
0 = {File@84956} "/Users/tnorbye/.gradle/caches/transforms-4/5126fdfcbb5a995f09b8be45eb610aef/transformed/desugar_jdk_libs_configuration_nio-2.0.4-desugar-lint.txt"
1 = {File@84957} "/Users/tnorbye/.gradle/caches/transforms-4/fc5ceb7b5de2ee8487ba96f4a79c6608/transformed/D8BackportedDesugaredMethods.txt"
What we do with these files is to "merge" them. This was just reading all the signatures from both files and sorting them. When lint is checking methods it just does a binary search.
But in this case, we're getting these methods from the d8 backport list:
java/util/Objects#checkFromIndexSize(JJJ)J
java/util/Objects#checkFromToIndex(JJJ)J
java/util/Objects#checkIndex(JJ)J
And we're getting this method from the library desugaring list:
java/util/Objects
This means that we end up with this in the signature list:
java/util/Objects
java/util/Objects#checkFromIndexSize(JJJ)J
java/util/Objects#checkFromToIndex(JJJ)J
java/util/Objects#checkIndex(JJ)J
This is wrong; the first line implies that all the other three are included. But in a binary search, if our midpoint hits one of the specific methods, we'll conclude that the match must be later in the list, so we'll falsely decide the method isn't there.
I need to fix the merging of signature files to not just concatenate but to drop specific methods and fields if the other file lists the whole class.
I don't think this is a recent regression, but I think this is showing up now through a combination of the desugaring files including newly fully backported classes, and there's luck involved based on how binary search proceeds.
tn...@google.com <tn...@google.com> #20
So I see two bugs listed in your table in
For the second one, I see that lint is passed this single database file: /Users/tnorbye/.gradle/caches/transforms-4/6cf6a445b18927988f27d9e2411efbbe/transformed/D8BackportedDesugaredMethods.txt
And that file does not contain requireNonNullElseGet
:
$ grep Objects /Users/tnorbye/.gradle/caches/transforms-4/6cf6a445b18927988f27d9e2411efbbe/transformed/D8BackportedDesugaredMethods.txt | grep requireNon
java/util/Objects#requireNonNull(Ljava/lang/Object;)Ljava/lang/Object;
java/util/Objects#requireNonNull(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
java/util/Objects#requireNonNullElse(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
Is this a problem in AGP/sync? cc: Scott
sg...@google.com <sg...@google.com> #21
Found the issue in AGP for the second bug. When calling D8DesugaredMethodsGenerator.generate
the minSdk
is not passed, so it defaults to 1. Therefore changing from 21 to 24 does not make a difference (except for the red squiggles under Supplier
goes away). When building the BackportedMethodListCommand
an additional call to setMinApiLevel
on the builder with the actual minSdk
is missing
Running the command line version of the tool without --min-api
gives exactly the list in
java -cp build/libs/r8.jar com.android.tools.r8.BackportedMethodList --lib third_party/android_jar/lib-v34/android.jar | grep Objects | grep requireNon
java/util/Objects#requireNonNull(Ljava/lang/Object;)Ljava/lang/Object;
java/util/Objects#requireNonNull(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
java/util/Objects#requireNonNullElse(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
tn...@google.com <tn...@google.com> #22
bi...@google.com <bi...@google.com>
bi...@google.com <bi...@google.com> #24
(2) With core library desugaring off, and minSdkVersion 24, lint flags requireNonNullElseGet
Fixed with Ib00094d61dbc26ff49928855ebe8dcdedf5ecf48
Close the ticket based on
an...@google.com <an...@google.com> #25
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 Feature Drop | 2024.1.2 Canary 6
- Android Gradle Plugin 8.6.0-alpha06
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!
to...@yahoo.com <to...@yahoo.com> #26
glad to confirm this is now working fine :)
Even with Plugin 8.5.0
Description
Lint shows NewApi warnings in Android Studio despite using coreLibraryDesugaring in the main application module. I followed the official documentation for adding desugaring, but it shows the errors both an existing multi-module project and a newly created single module project.
The API I tested with was ArrayList#removeIf(..).
It does show the warning:
- for JVM target 8, 11 and 17
- in java as well as in kotlin classes
- for single module projects as well as for multi module projects
I made sure the desugaring was actually working by building the app without it. It crashes to 21 WITHOUT the library enabled. It does NOT crash on 21 WITH the library enabled, but the warning is still there.
I attached a demo project as zip.
STEPS TO REPRODUCE:
1. Create a new Project with Android Studio.
2. Add coreLibraryDesugaring as written down in
3. Call ArrayList<..>().removeIf(..).
ATTACH SCREENSHOTS/RECORDINGS OF THE ISSUE
-
ATTACH LOG FILES (Select Help > Show Log in Files, or Show Log in Finder on a Mac)
-
------------------
IMPORTANT: Please read
all required information.
------------------
Studio Build: Iguana | 2023.2.1 / Build #AI-232.10227.8.2321.11479570, built on February 21, 2024
Version of Gradle Plugin: 8.3
Version of Gradle: 8.4
Version of Java: 17
OS: Windows 11