Status Update
Comments
pa...@nearside.com <pa...@nearside.com> #2
Update: compilation works fine, both through AS and terminal.
Modules are implementation
dependencies, but that oughtn't be an issue since they're direct dependencies.
xa...@google.com <xa...@google.com>
lu...@google.com <lu...@google.com> #3
Hi, thanks for the bug. I'm trying to reproduce this. First, does clicking "Invalidate caches / restart" under "File" have any affect? Next, if possible could you send a reproducible project?
If not, I have some questions which might help figure out the root cause:
- Do you see the relevant R classes from java files?
- If you type simply "R" and do code completion, do you see any other examples of R classes?
- Does the package name you use for the R class match what is in that modules' AndroidManifest.xml
- Can you access any other module R class from the :app module?
pa...@nearside.com <pa...@nearside.com> #4
Hi!
"Invalidate caches / restart"
It fixes...some of them, sometimes? (I have like ~4 Android lib modules, and ~5 pure Kt modules). Sometimes, it'll fix it and then it'll break the next time I force compilation across multiple modules. (Not a super useful answer I'm sorry)
Do you see the relevant R classes from java files?
I created a fake Java file just to test this; seems like it's broken for Java as well? (See attached)
If you type simply "R" and do code completion, do you see any other examples of R classes?
Vaguely related to the screenshot my original post (helpfully named Thu Dec 10 2020 18:36:05 GMT-0500 (Eastern Standard Time).png
) - in most (but not all!) files, R.
doesn't resolve to anything. R.
works pretty well in :app
, but none of the other feature modules.
Does the package name you use for the R class match what is in that modules' AndroidManifest.xml
Yes; I use
Can you access any other module R class from the :app module?
No, only the :app
module's R.
resolves in :app
☹️
if possible could you send a reproducible project?
Alas, it's a closed-source app. If you're plumb out of ideas, I could ping Xav through other means and see if we can get something set up.
BTW FWIW this has been broken for a while, at least the whole AS/AGP 4.2 line; I'm just a jerk and didn't file the bug until now.
pa...@nearside.com <pa...@nearside.com> #5
Attached as a screenshot is the line it's complaining about.
Let me know what additional info I can provide!
pa...@nearside.com <pa...@nearside.com> #6
lu...@google.com <lu...@google.com> #7
Hi again. Good news, I think I've fixed this! The fix is due to be released in Android Studio 2020.3.1 Canary 15 which should be released soon. If you could let me know if you still experience this issue when that version is released, that would be much appreciated!
pa...@nearside.com <pa...@nearside.com> #8
I awaited AF C15 with bated breath, and unfortunately the issue still happens 😭
Things I tried:
- stopping (gw --stop) + re-syncing Gradle
- rebuilding the project
- Invalidate Caches + Restart AS
No dice!
I've attached logs on the off-chance that that's useful, as well as some more recent screenshots showing the same issue.
Let me know how I can help debug!
lu...@google.com <lu...@google.com> #9
Hi. That's quite unfortunate, thanks for the quick update though. If you could construct a small sample project that triggers this bug for you, that would be extremely helpful. I have a feeling it has to do with the project structure, any info on dependencies and modules will also be helpful (eg. are you using dynamic feature modules? etc). Also, do you re-use the same module package name in multiple AndroidManifest.xml files? Thanks again!
pa...@nearside.com <pa...@nearside.com> #10
While I see if there's a minimal sample project I can repro the issue in, here's some quick info on my corp project that this is happening in:
- obviously
android.nonTransitiveRClass=true
is set in the Gradle properties - 20 modules, probably 3/4 of them are Android lib modules
- I have a
buildSrc
module with my dependency coordinates and a custom plugin that just externalizes theandroid { .. }
block across all my android lib modules - use
.kts
for allbuild.gradle
files (RIP my sync time) - no dynamic feature modules
- most of the modules are nested (e.g.
:features:dashboard
) - core library desugaring is enabled
- all modules have their own package namespace (I use
https://github.com/GradleUp/auto-manifest to generate manifest files)
The project structure is roughly:
- app
- models
- common
- interfaces, annotations
- core
- analytics, network, db, etc.
- features
- dashboard, login, etc.
In the :app
module, "local" resources work -- e.g. R.string.whatever
. Resources from other modules don't work - e.g. hatch.core.design.R.string.anotherWhatever
won't resolve in the IDE.
In library modules, no resources resolve, local or otherwise.
lu...@google.com <lu...@google.com> #11
I believe I've found the underlying issue here. The GradleUp auto-manifest gradle plugin creates AndroidManifest.xml files in directories that the IDE does not yet fully support. We are working on a solution for this and I will update this bug this bug when a fix has been released.
For a workaround:
- Instead of using auto-manifest gradle plugin to generate library module manifests, manually create the AndroidManifest.xml in each of your Android library modules. This can have the same contents as the auto-manifest generated manifest, but needs to be placed in the usual directory structure for modules (eg.
MyApplication/lib/src/main/AndroidManifest.xml
).
If there are any users experiencing unresolved resources with nonTransitiveRClass=true reading this, who are not using auto-manifest gradle plugin, please open a new bug and I will investigate. Thanks!
lu...@google.com <lu...@google.com> #12
A fix for this should be included in Arctic Fox Beta 1. Although the GradleUp auto-manifest is not officially supported, it may now work as intended. Marking this as fixed, but I will update this bug if anything relevant comes up!
pa...@gmail.com <pa...@gmail.com> #13
When I 'gradle assembleRelease' with:
1 - AGP 8.0.1 && android.nonTransitiveRClass=false : OK
2 - AGP 8.0.1 && android.nonTransitiveRClass=true : OK
3 - AGP 8.0.2 && android.nonTransitiveRClass=false : OK
4 - AGP 8.0.2 && android.nonTransitiveRClass=true : NOT OK : error is:
C:\Users\<USER>\<PATH_TO_MY_PROJECT>\<MY_MODULE>\build\generated\data_binding_base_class_source_out\release\out\<MY>\<MODULE>\<PACKAGE>\databinding\SharedBrowserFragmentBinding.java:73: error: cannot find symbol
View root = inflater.inflate(R.layout.shared_browser_fragment, parent, false);
^
symbol: variable shared_browser_fragment
location: class layout
Note:
R.layout.shared_browser_fragment is defined in another (library) module of the same project
So, for now, I stick to "AGP 8.0.1 && android.nonTransitiveRClass=true" and I hope you'll be able to reproduce this bug.
My config:
Android Studio Flamingo | 2022.2.1 Patch 2
Build #AI-222.4459.24.2221.10121639, built on May 12, 2023
Runtime version: 17.0.6+0-b2043.56-9586694 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 3072M
Cores: 8
Registry:
external.system.auto.import.disabled=true
ide.text.editor.with.preview.show.floating.toolbar=false
ide.instant.shutdown=false
gradle.version.catalogs.dynamic.support=true
Non-Bundled Plugins:
String Manipulation (9.7.1)
Lombook Plugin (0.34.1-2019.1)
Key Promoter X (2022.3.1)
net.seesharpsoft.intellij.plugins.csv (3.2.0-222)
mobi.hsz.idea.gitignore (4.4.2)
Docker (222.4459.28)
Dart (222.4582)
DBN (3.3.8905.0)
com.developerphil.adbidea (1.6.9)
io.flutter (73.0.2)
Batch Scripts Support (1.0.13)
lu...@google.com <lu...@google.com>
an...@google.com <an...@google.com>
je...@google.com <je...@google.com>
pa...@gmail.com <pa...@gmail.com> #14
Short message:
I am not able to reproduce the problem anymore.
Maybe because I
- (stopped Android Studio)
- deleted some folders under C:\Users\<USER_NAME>\AppData\Local\Google\AndroidStudio2022.2\ as explained here
- then restarted Android Studio
(Just doing "invalid cache and restart" didn't help)
-----
Long message:
Some time ago, I did 'side-load' a 'tweaked' version of Lombok Plugin (0.34.1-2019.1) (tweak consist in increasing version number to allow plugin installation: no code changes in Lombok code base)
I proceeded as explain here:
BUT I just noticed that this tweaked plugin does breaks auto-completion in some project in Android Studio!
(I shared this info on SO )
So I deactivated this plugin in my Android Studio and then I though about this nonTransitiveRClass issue, so I gave another try and ... I can now successfully build my project using "AGP 8.0.2 & android.nonTransitiveRClass=true"
I tried to reproduce the problem by reactivating the Lombok plugin: and it still works!
So... I am not able to reproduce the issue anymore.
Odd thing is that my config is the same (see at the end of this message)
Possible explanation:
When I tried to fix my auto-completion issue (caused by Lombok), I tried many solution, including this one: deleting some folders as explained here:
So, in folder C:\Users\<USER_NAME>\AppData\Local\Google\AndroidStudio2022.2\ , I deleted the following folders:
caches
compiler
compile-server
conversion
external_build_system
frameworks
-> maybe this explains why the "nonTransitiveRClass=true" issue is now gone...?
Note a bout Lombok plugin:
It looks like Lombok plugin will (hopefully) be bundled in Android studio Hedgehog cfr
in the mean time, some developers (including me) are trying to used it cfr
-----
My Config:
Android Studio Flamingo | 2022.2.1 Patch 2
Build #AI-222.4459.24.2221.10121639, built on May 12, 2023
Runtime version: 17.0.6+0-b2043.56-9586694 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 3072M
Cores: 8
Registry:
external.system.auto.import.disabled=true
ide.text.editor.with.preview.show.floating.toolbar=false
ide.instant.shutdown=false
gradle.version.catalogs.dynamic.support=true
Non-Bundled Plugins:
String Manipulation (9.7.1)
Lombook Plugin (0.34.1-2019.1)
Key Promoter X (2022.3.1)
net.seesharpsoft.intellij.plugins.csv (3.2.1-222)
mobi.hsz.idea.gitignore (4.4.2)
Docker (222.4459.28)
Dart (222.4582)
DBN (3.3.9501.0)
com.developerphil.adbidea (1.6.9)
io.flutter (74.0.2)
Batch Scripts Support (1.0.13)
am...@google.com <am...@google.com> #15
Sorry for taking such a long time to look into this. I'm closing this as obsolete since you've reported the issue being fixed. Feel free to open a new bug if the issue still exists.
pa...@gmail.com <pa...@gmail.com> #16
Just one question: is Android Studio now compatible with Lombok plugin?
Thanks
Description
Build: AI-202.7319.50.2031.7006259, 202012020750,
AI-202.7319.50.2031.7006259, JRE 11.0.8+10-b944.6842174x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.15.7
Setup:
gradle.properties
file, I have the following line enabled::app
, and:core:design
, amongst others), each with its own subpackage;app
has.app
,:core:design
has.core.design
, etc.Consequently, in the UI, zero non-local-module R files are resolved -- e.g. if I'm in
:app
it'll resolve that.app.R
, but not.design.R
. This means autocomplete is broken for 75% of my use-case.Attached are some screenshots showing different use-cases, all of them with "external" R files not resolving.