Status Update
Comments
vi...@google.com <vi...@google.com>
da...@google.com <da...@google.com> #2
Sorry, I believe my team can't act on this information in its current state. We're not sure how to reproduce.
Can you either provide a repro project? Or a very clear set of repro steps starting with a new project?
ch...@gmail.com <ch...@gmail.com> #3
Here you are test project.
da...@google.com <da...@google.com> #4
Thank you! We'll take a look.
da...@google.com <da...@google.com> #5
One thing I just learned from the data binding compiler folks is that <fragment> tags are actually ignored intentionally, so if you look at the code the compiler generates, any <fragment> with an id on it won't be found there.
In other words, this:
activity_main.xml
<fragment
android:id="@+id/id1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/id2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:text="Hello World!" />
generates this:
ActivityMainBinding.java
public final class ActivityMainBinding implements ViewBinding {
@NonNull
private final ConstraintLayout rootView;
@NonNull
public final TextView id2;
private ActivityMainBinding(@NonNull ConstraintLayout rootView, @NonNull TextView id2) {
this.rootView = rootView;
this.id2 = id2;
}
^ Notice no id1
in there
So for me, what I need to do is make sure <fragment> tags don't generate binding fields in the IDE.
But for you, there's no reason to wait for that fix, because it doesn't help you. I'm not sure what you're trying to accomplish here, but you'll have to do it without using an ID on your <fragment> tag. This seems like an intentional design decision by the data binding team.
da...@google.com <da...@google.com>
da...@google.com <da...@google.com> #6
Starting in 4.2 Canary 9, we will no longer show fields for <fragment> tags to match the behavior of the data binding compiler.
Apologies to OP because this probably isn't the fix they were hoping for :)
See my
Description
While using ViewBinding with layout that contains
fragment
element, incompatibility attribute with type offragment
is created. I expected, it will be created attribute of theandroid:name
type.Build: AI-193.6911.18.40.6626763, 202006250242,
AI-193.6911.18.40.6626763, JRE 1.8.0_242-release-1644-b3-6222593x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.15.3, screens 1680x1050; Retina
AS: 4.0.1; Kotlin plugin: 1.3.72-release-Studio4.0-5; Android Gradle Plugin: 4.0.1; Gradle: 6.1.1; NDK: from local.properties: 21.3.6528147, latest from SDK: 21.3.6528147; LLDB: LLDB 3.1 (revision: 3.1.4508709); CMake: from local.properties: (not specified), latest from SDK: 3.10.2, from PATH: (not found)