Status Update
Comments
ja...@google.com <ja...@google.com> #2
There are integration tests that this works for AGP about to land in ag/10416336 so it seems to be something on the Studio side.
da...@google.com <da...@google.com> #3
Can you look in your idea.log and see if you see the message BindingXmlIndex queried outside of smart mode.
?
[Deleted User] <[Deleted User]> #4
Just checked; the text "BindingXmlIndex" is not in the log at all.
da...@google.com <da...@google.com> #5
Let me take a quick look. This might be something different than what I was originally thinking.
da...@google.com <da...@google.com> #6
Yikes, unless I'm missing something, this case is totally uncovered far more than just data binding / view binding. The UI for creating androidTest/res/layout is itself quite limited (it's only easy if I want to add a layout to src/main/res, src/debug/res, and src/release/res), and all sorts of other things are breaking.
So yeah, view binding and data binding completions under androidTest are definitely busted, but we're just the tip of the iceberg. And given the fact that our tech is built on top of other tech, we probably need to figure out how to prioritize fixing the underlying issues first.
That's my current understanding, anyway.... I'll find out who to chase down next.
da...@google.com <da...@google.com> #8
Dev note: Pasting excellent notes here I got from a coworker, for when I come back to this.
test R classes should work, we even have com.android.tools.idea.res.TestRClassesTest
there's com.android.tools.idea.res.ResourceRepositoryManager#getTestAppResources
for a start, you need to add a parameter to BindingScopeEnlarger#getAdditionalResolveScope to know if you should include androidTest classes or not
for reference have a look at com.android.tools.idea.res.ModuleRClass#getScopeType
and ProjectLightResourceClassService#getModuleRClasses where we compute both sets
and AndroidResolveScopeEnlarger.Companion#computeAdditionalClassesForModule
is...@google.com <is...@google.com>
an...@google.com <an...@google.com>
an...@google.com <an...@google.com> #10
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 | 2024.2.1 Canary 9
- Android Gradle Plugin 8.7.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!
Description
* Version of Gradle Plugin: 3.6.0 (also 4.0 beta 1)
* Version of Gradle: 5.6.4 (also 6.1.1)
* Version of Java: 1.8
* OS: MacOS
**Steps to reproduce:**
1. Create a project with ViewBinding enabled.
2. Create a layout under the androidTest/ source directory (rather than main/).
* Note that the layout file has red error highlighting but is actually accessible at
`your.package.test.R.layout` and can be inflated in an instrumented test just fine. I
don't know if this is related or is a separate bug.
3. Attempt to import `your.package.test.databinding.YourLayoutBinding` in an instrumented
test class.
**Expected:** The Binding class can be imported and used.
**Actual:** The Binding class cannot be imported.