Fixed
Status Update
Comments
jv...@google.com <jv...@google.com>
an...@google.com <an...@google.com>
an...@google.com <an...@google.com> #3
Thanks for the demo project - it made it much quicker to track this down! I've made a fix which will be available in an upcoming canary build.
an...@google.com <an...@google.com> #4
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 Jellyfish | 2023.3.1 Canary 1
- Android Gradle Plugin 8.4.0-alpha01
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
####################################################
Please provide all of the following information, otherwise we may not be able to route your bug report.
####################################################
1. Describe the bug or issue that you're seeing.
While editing a kotlin file, the viewbinding is incorrectly claiming viewbinding class unavailable
2. Attach log files from Android Studio
2A. In the IDE, select the Help..Collect Logs and Diagnostic Data menu option.
2B. Create a diagnostic report and save it to your local computer.
2C. Attach the report to this bug using the Add attachments button.
3. If you know what they are, write the steps to reproduce:
IDEs
I'm running IDE version:
Android Studio Hedgehog | 2023.1.1
Build #AI-231.9392.1.2311.11076708, built on November 9, 2023
Runtime version: 17.0.7+0-b2043.56-10550314 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
I'm using Windows 10
NOTE Error is identical in IntelliJ IDEA 2023.3.1 (Ultimate Edition) - Build #IU-233.11799.300, built on December 12, 2023
Firstly, I'll be clear, this project compiles and runs absolutely fine under gradle, it is just the IDE reporting missing fields essentially so red squiggle underlining incorrectly.
I have a possibly unusual project setup,
I have two android App modules. One is called app (the default), the other is app_my_second_project
Both modules have a layout resource xml file called my_section.xml which is imported into another file my_fragment.xml
my_section.xml imports another file; my_fields.xml
Each project has its own android namespace (one is com.me.project, the second is com.me.project.other)
Both projects have a Fragment - MyFragment.kt (different packages but same name) which is the tools:context for my_fragment.xml.
Both projects have a MaterialCardView- MySection.kt (different packages but same name) which is the tools:context for my_section.xml.
In the first project (com.me.project) MySection.kt, I import and use the binding MyFieldsBinding which I access from the MySectionBinding instance.
The bug is it shows an error "cannot access class 'class com.me.project.other.databinding.MyFieldsBinding' check your module classpathfor missing or conflicted dependencies". In the error detail it says:
com.me.myproject.databinding.MySectionBinding
@NonNull
public final com.me.myproject.other.databinding.MyFieldsBinding fields
<MyIdeProject>.app.main
I have checked the class fiels in the build folder and the class MySectionBinding does have an instance of MyFieldsBinding inside it, and it is NOT referring to the package com.me.project.other.databinding (second project), so it is all doing the right thing, the IDE is just rather curiously getting a reference to the second project somehow.
I've tried to add a tools:context attribute to the import within the fragment xml file, but this doesn't help.
In addition to logs, please attach a screenshot or recording that illustrates the problem.
For more information on how to get your bug routed quickly, see
Build: AI-231.9392.1.2311.11076708, 202311091610
AI-231.9392.1.2311.11076708, JRE 17.0.7+0-b2043.56-10550314x64 JetBrains s.r.o., OS Windows 10(amd64) v10.0 , screens 9600.0x5400.0
AS: Hedgehog | 2023.1.1
Kotlin plugin: 231-1.9.10-release-459-AS9392.1.2311.11076708
Android Gradle Plugin: 8.2.0
Gradle: 8.4
Gradle JDK: Oracle OpenJDK version 20.0.2
NDK: from local.properties: (not specified), latest from SDK: 26.1.10909125
CMake: from local.properties: (not specified), latest from SDK: 3.22.1-g37088a8-dirty, from PATH: (not found)
```