Status Update
Comments
mu...@gmail.com <mu...@gmail.com> #2
I'm trying to repro this in a clean project, but I'm unable to
In my actual project, the only thing that changed since lint completed successfully is:
Ran the "nonTransitiveRClass" migration from Android Studio, which:
- Added
android.nonTransitiveRClass=true
togradle.properties
- Fully qualified any
R
that came from another module
I then manually:
- created import aliases for any of the fully qualified
R
from step 2 - added the missing project dependency for any module that was relying on transitive R
I tried keeping everything else and changing android.nonTransitiveRClass=true
to android.nonTransitiveRClass=false
, but the false positive still occurs.
Looking at what's triggering the false positives, two of the modules are used by almost every other module in the app. They both have lots of resources, but only 13 resources between the two of them are triggering the false positive.
There are three other modules that are triggering the false positive (6 resources between all of them causing it).
no...@gmail.com <no...@gmail.com> #3
I can confirm that we have the same issue, and it's reproducible with AGP 7.0.0-beta03, the same case, android.nonTransitiveRClass=true and type alias. Removing type alias helps and the resource is not marked as unused anymore. It looks that this is the case only for complex module structure (when :app:lintDebug run with checkDependencies=true and one of libraries modules references another library module resource with typealias, maybe it also somehow related when all dependencies are implementation
, so it not exposed directly to app)
Also we had no issue before updating to AGP 7.0.0 from 4.0 and android.namespacedRClass=true
fe...@gmail.com <fe...@gmail.com> #4
I was finally able to reproduce this (repro project attached).
The root problem seems to be that we don't have the R.jar files for upstream modules provided in the lint model as part of libraries. As a result, attempts to resolve references into that R class will fail. Lint has some heuristics for dealing with incomplete class paths so it will recognize a reference to R.type.name even if it does not resolve to an actual field, but that does not work with import aliases where any identifier could reference an R class -- lint does look at every reference to see if this is the case, but that requires resolve to work and there is nothing about the name that suggests it's a resource.
In the test example, a string resource is defined in lib2 (@string/lib2), which is referenced from code in lib1 (imported as String_lib2), and app depends on lib1. (I actually created a bunch of permutations to try to reproduce this bug, but there was only one scenario which failed and I've pruned things down to just this.) When you run ./gradlew :app:lint it will complain that @string/lib2 is unused, which is not the case.
I think the root problem here is that the library passed in the lint model for the dependency does not include its R.jar, only the classes.jar. It's nowhere under the library definition folder:
./out/jars/classes.jar
./out/res/values/values.xml
./out/AndroidManifest.xml
./out/META-INF/com/android/build/gradle/aar-metadata.properties
./out/META-INF/com/android/build/gradle/lint-model-metadata.properties
./out/proguard.txt
./out/R.txt
I could probably load the lint model for the dependency myself and locate the R.jar in the classes/ folder, but that seems hacky. Shouldn't the AndroidLibrary model provide the R.jar instead of (or in addition to) the R.txt file when using namespaced R classes?
(Note: Lint is currently skipping anything not a LintModelExternalLibrary from the classpath so we'll need to tweak that too, but as I was debugging this and thinking to fix it by pulling in the jars for local dependencies, which is necessary with partial analysis, I realized that even adding that wouldn't help since the R.jar's aren't there.)
Repro project: ./gradlew :app:lint -- will list R.string.lib2 as unused, though it's referenced from Lib1.kt.
ro...@gmail.com <ro...@gmail.com> #5
I have created a workaround in lint for this: if resolving a symbol fails, then it will check the imports to see if it matches an alias that itself looks like a resource reference (.R.type.name) then it will visit the resource reference that way. This fixes this bug.
HOWEVER -- having unresolved symbols is bad; there are potentially other things broken. For example when I invoke Go To Declaration on the aliased resource identifier, it doesn't in fact go to declaration. Therefore, we need to make sure that the way android.nonTransitiveRClass
is implemented preserves the old semantics in the tools. Over to AGP.
ra...@google.com <ra...@google.com>
al...@gmail.com <al...@gmail.com> #6
Ah I think this is a regression from us adding runtime dependencies as well as compile, the code in CheckDependenciesLintModelArtifactHandler
means we prefer runtime artifacts when we should prefer compile artifacts, which have the additional R class baked in. i.e. just reversing the order of the maps would mean the compile dependencies will show through
al...@gmail.com <al...@gmail.com> #7
I just realize I might have sent you in the wrong direction with making the R classes resolve - We might need to have a separate exploded AAR for lint that has the R.jar merged in - the problem currently is that even the lint aar artifact on the compile classpath doesn't have the R classes for lint In normal compilation they're present in the compile classpath R jar
ya...@google.com <ya...@google.com> #8
Why does it have to be a separate AAR? In the project tree I see all the R.jar files:
lib1/build/intermediates/compile_r_class_jar/debug/R.jar
lib2/build/intermediates/compile_r_class_jar/debug/R.jar
app/build/intermediates/compile_and_runtime_not_namespaced_r_class_jar/debug/R.jar
When the lint model is fed to the lib2 analysis task, I would think that the LintModelModuleLibrary for lib1 should include the lib2 R.jar. (Right now LintModelModuleLibrary only takes a single lintJar:File; we probably need to switch to List<File> as is done for some other library types, like LintModelExternalLibrary.
ya...@google.com <ya...@google.com>
[Deleted User] <[Deleted User]> #9
For lint to be up-to-date it needs to actually depend on the things it reads, so adding it to the model without also creating the dependency isn't correct. We could handle it separately, but either way we need to change what we export from libraries to include it.
rh...@css-design.com <rh...@css-design.com> #10
Issue still exists in AGP 7.0.1
ya...@google.com <ya...@google.com>
se...@gmail.com <se...@gmail.com> #12
I updated dependencies on #4 comment project and it fixed for original code, but to reproduce it enough to change import alias from the resource itself to alias for R file (which arguably the much more common use case):
- import com.android.tools.test.lib2.R.string.lib2 as String_lib2
+ import com.android.tools.test.lib2.R as Lib2R
- println(String_lib2)
+ println(Lib2R.string.lib2)
Attached updated project
ya...@google.com <ya...@google.com> #13
Issue still exists in 7.1.0 for us
dk...@3cx.com <dk...@3cx.com> #14
The reproducer from
sp...@gmail.com <sp...@gmail.com> #15
This has been fixed. The fix will be in AGP 7.3.0-alpha09 and/or 7.3.0-beta01.
Change-Id: Ia15bd84ffc0ed963b431f6fe1d89f19f5ca27cbe
na...@gmail.com <na...@gmail.com> #16
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 Dolphin Canary 9 (2021.3.1.9)
- Android Gradle Plugin 7.3.0-alpha09
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!
ne...@gmail.com <ne...@gmail.com> #17
I checked test project and my own project and it looks that bug was fixed in 7.3.0-alpha09
mr...@gmail.com <mr...@gmail.com> #18
xi...@turingvideo.com <xi...@turingvideo.com> #19
It always shows "External file changes sync may be slow: File watcher failed repeatedly and has been disabled".
What is the cause and how can I dismiss this warning message ?
thanks
ra...@gmail.com <ra...@gmail.com> #20
The workaround is to replace the file fsnotifier in your Android Studio binary directory with one from another JetBrains IDE, say Intellij Idea. You can download the file here:
If you're running Android Studio as a snap like myself, unfortunately you're gonna have to wait for this problem to (hopefully) get fixed on the next minor release.
mr...@gmail.com <mr...@gmail.com> #21
su...@gmail.com <su...@gmail.com> #22
after
this add do
>>>>>> <option name="delegatedBuild" value="false" /> <<<<<<<<<<<<<<<<<<<<
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
>>>>>>>>>>>>>>>>>> <option name="delegatedBuild" value="false" /> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
</GradleProjectSettings>
</option>
</component>
</project>
ya...@google.com <ya...@google.com> #23
this is fixed in Android Studio Electric Eel - please update Studio if you are on canary canary.
and fix would be available on next Dolphin and Chipmunk releases as well.
ra...@gmail.com <ra...@gmail.com> #24
My system is running Ubuntu 20.04.4 LTS
Getting this associated warning on Android Studio startup multiple times:
WARN - pl.local.NativeFileWatcherImpl - /snap/android-studio/123/android-studio/bin/fsnotifier: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /snap/android-studio/123/android-studio/bin/fsnotifier)
WARN - pl.local.NativeFileWatcherImpl - Watcher terminated with exit code 1
And on the notifications:
External file sync changes may be slow
File watcher failed repeatedly and has been disabled
I checked and I clearly don't have GLIBC version 2.33 in my system:
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_2.18
GLIBC_2.22
GLIBC_2.23
GLIBC_2.24
GLIBC_2.25
GLIBC_2.26
GLIBC_2.27
GLIBC_2.28
GLIBC_2.29
GLIBC_2.30
GLIBC_PRIVATE
GNU C Library (Ubuntu GLIBC 2.31-0ubuntu9.9) stable release version 2.31.
It's also not generally recommended to manually install the latest GLIBC on a system as described here:
Any chance this will be fixed on the next patch release?
ha...@ornl.gov <ha...@ornl.gov> #25
Android Studio Chipmunk | 2021.2.1 Patch 1
Build #AI-212.5712.43.2112.8609683, built on May 18, 2022
Runtime version: 11.0.12+0-b1504.28-7817840 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 4.18.0-394.el8.x86_64
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin (212-1.7.10-release-333-AS5457.46)
Current Desktop: GNOME
ne...@gmail.com <ne...@gmail.com> #26
It looks working however it has a different image from my own compile version on Debian Bullseye.
$file projects/fsnotifier/fsnotifier && file ~/Downloads/fsnotifier
projects/fsnotifier/fsnotifier: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=358a3c86714f29c23ada3e11d528b764f8022407, for GNU/Linux 3.2.0, not stripped
Downloads/fsnotifier: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, not stripped
Downloaded version is that from IntelliJ GitHub.
ah...@avirohealth.com <ah...@avirohealth.com> #28
ya...@google.com <ya...@google.com> #29
Android Studio Chipmunk Patch 2 is released please update to latest version to resolve fsnotifier issue.
gr...@gmail.com <gr...@gmail.com> #30
Looks good now. Thank you.
gm...@gmail.com <gm...@gmail.com> #31
Yeah, seems to be fixed in Chipmunk Patch 2. :)
For some reason this isn't mentioned in the
ra...@gmail.com <ra...@gmail.com> #32
Since Ubuntu's first point release is now available, I upgraded to Jammy Jellyfish and this problem is gone.
Description
Build: AI-213.6777.52.2113.8305692, 202203160046,
AI-213.6777.52.2113.8305692, JRE 11.0.13+0-b1751.21-8125866x64 JetBrains s.r.o., OS Linux(amd64) v5.13.0-35-generic, screens 3440.0x1440.0
AS: Dolphin | 2021.3.1 Canary 7; Kotlin plugin: 213-1.6.20-M1-release-for-android-studio-AS6777.52; Android Gradle Plugin: 7.3.0-alpha07; Gradle: 7.4; Gradle JDK: version 11.0.13;
I have done a clean installation of Ubuntu 20.04, downloaded latest Android Studio(canary and lates bumblebee) and on every start warning appears "File watcher failed to start" or in idea.log:
Launching fsnotifier from command line gives the same error. Note: flag executable is set on this file.
The only workaround I have found that works - download Intellij Idea and copy fsnotifier from its bin folder. With this version of fsnotifier Android Studio successfully launches fsnotifier.