Fixed
Status Update
Comments
uc...@google.com <uc...@google.com> #2
not reproduced , can you share sample project to triage this issue
ma...@gmail.com <ma...@gmail.com> #3
You can try the example there: https://github.com/martinbonnin/MergeTagExample
Especially, this layout file:https://github.com/martinbonnin/MergeTagExample/blob/master/app/src/main/res/layout/example_view.xml
Android studio complains that 'Element merge is not allowed here' and autocomplete does not work.
Especially, this layout file:
Android studio complains that 'Element merge is not allowed here' and autocomplete does not work.
ma...@gmail.com <ma...@gmail.com> #4
Something else I just noticed: if there's an error in the XML file, clicking the file in the messages windows takes you to the generated file (build/intermediates/...) instead of the original layout file.
ni...@google.com <ni...@google.com>
ma...@gmail.com <ma...@gmail.com> #5
Also, it makes lint and 'find usages' useless, it's really cumbersome to develop. Or should we use another pattern instead ?
sh...@gmail.com <sh...@gmail.com> #6
the documentation says that <layout /> does not allow <merge /> or <include /> as direct children
ma...@gmail.com <ma...@gmail.com> #7
The documentation says:
"Data binding does not support include as a direct child of a merge element."
This means <include> cannot be a child of <merge>.
It doesn't say anything about <merge> being a child of <layout>.
Do I miss something ?
"Data binding does not support include as a direct child of a merge element."
This means <include> cannot be a child of <merge>.
It doesn't say anything about <merge> being a child of <layout>.
Do I miss something ?
ia...@gmail.com <ia...@gmail.com> #8
The part about <include> isn't related to the discussion. The question is whether <merge> is allowed in data binding layouts.
It seems to work in practice, but android studio show a warning "Element merge not allowed here"
It seems to work in practice, but android studio show a warning "Element merge not allowed here"
aa...@sociotopia.com <aa...@sociotopia.com> #9
This is still reproducible in AS 3.0
br...@gmail.com <br...@gmail.com> #10
It would be necessary to be able to specify some attribute on the merge, something like <merge tools:showAs="LinearLayout"> for AS to be able to render it correctly too.
jo...@gmail.com <jo...@gmail.com> #11
We are seeing the same with random tags, sometimes is any element inside an AppBarLayout, sometimes is other elements, but, the problem is if that the IDE assumes there's an issue any autocomplete in that level is busted and will not work, which only slows down everything, we have seen this in some files since 2.3.3 and is still happening in 3.1 canary 8, it will vary which files depending on version, specifically 2.3.3 shows this less than 3.0+ versions.
jo...@gmail.com <jo...@gmail.com> #12
But, once a file shows this error, it will keep showing it for all of us in the same version, so is something we can reproduce consistently
[Deleted User] <[Deleted User]> #13
So the warning is still there but <merge> works inside <layout> just fine. It's just the warning that's misleading.
[Deleted User] <[Deleted User]> #14
Not only is the warning annoying... In AS 3.2 Beta 1 auto completion doesn't work inside XML when <merge> is used inside <layout>.
yu...@gmail.com <yu...@gmail.com> #15
Is there any way the priority can be bumped on this? It's insanely difficult to develop without auto completion here. We keep having to change the merge tag to the containing one when editing the file and back to merge before commit. Android Studio 3.2 RC3
tn...@google.com <tn...@google.com>
da...@google.com <da...@google.com> #16
Hey all, I know this bug has been quiet for a while, so I just wanted to say sorry about that. We've got a small team looking at data binding issues now, and we'll be sure to investigate this issue sooner than later.
kn...@google.com <kn...@google.com> #17
Looking through the history of this bug, I'm wondering if this bug is actually just a misundertanding.
<merge> is always a root tag. It surrounds xml that is intended to be re-used in another layout file.
So something like this *is* supported:
=====================
<merge>
<Button>
<TextView>
</merge>
=====================
<layout>
<data>...</data>
<LinearLayout>
<include layout="@layout/..." />
</LinearLayout>
</layout>
=====================
but neither of these are supported:
=====================
<layout>
<merge>
<Button>
<TextView>
</merge>
</layout>
=====================
=====================
<layout>
<data>...</data>
<include layout="@layout/..." />
<LinearLayout>
...
</LinearLayout>
</layout>
=====================
Does what I wrote here clear things up? Or is there something I'm still missing?
I can see there are some concerns about autocomplete, but I'm wondering if that's really part of this bug, or something I should be tracking in a separate bug...
<merge> is always a root tag. It surrounds xml that is intended to be re-used in another layout file.
So something like this *is* supported:
=====================
<merge>
<Button>
<TextView>
</merge>
=====================
<layout>
<data>...</data>
<LinearLayout>
<include layout="@layout/..." />
</LinearLayout>
</layout>
=====================
but neither of these are supported:
=====================
<layout>
<merge>
<Button>
<TextView>
</merge>
</layout>
=====================
=====================
<layout>
<data>...</data>
<include layout="@layout/..." />
<LinearLayout>
...
</LinearLayout>
</layout>
=====================
Does what I wrote here clear things up? Or is there something I'm still missing?
I can see there are some concerns about autocomplete, but I'm wondering if that's really part of this bug, or something I should be tracking in a separate bug...
al...@gmail.com <al...@gmail.com> #18
The case below happens when using databinding inside a compound view.
=====================
<layout>
<merge>
<Button>
<TextView>
</merge>
</layout>
=====================
I'm not sure if it is supported or not, but it certainly seems to be supported since it works as expected at runtime. The problem is that AS says that merge tag and the views inside merge tag are not allowed and autocomplete doesn't work inside that merge tag partially, for example doesn't suggest tags and attributes of the parentTag.
=====================
<layout>
<merge>
<Button>
<TextView>
</merge>
</layout>
=====================
I'm not sure if it is supported or not, but it certainly seems to be supported since it works as expected at runtime. The problem is that AS says that merge tag and the views inside merge tag are not allowed and autocomplete doesn't work inside that merge tag partially, for example doesn't suggest tags and attributes of the parentTag.
mo...@googlemail.com <mo...@googlemail.com> #19
As we want to use databinding in the merged file we are forced to use an outer layout as per your second example. That IS supported by the library at app run time because built apps run fine.
So I think this issue is a request to support that use case in AS' preview too. AS shows a warning as well as autocomplete problems, I assumed those are linked.
So I think this issue is a request to support that use case in AS' preview too. AS shows a warning as well as autocomplete problems, I assumed those are linked.
da...@google.com <da...@google.com>
da...@google.com <da...@google.com>
da...@google.com <da...@google.com> #20
This fix should land in 3.5 Canary 12.
To everyone who waited patiently on this bug, and for any (probably almost all) of you who surely gave up hope that this would ever get fixed, I'm sorry it took this long.
For a bit of context in case you are curious: I started working with a small team on an effort to improve data binding as part of the project marble initiative (https://android-developers.googleblog.com/2019/01/android-studio-33.html ). We first prioritized the major class of issues that affected all data binding users, from new users to experts alike (e.g. code completion, symbols not found, navigation, refactoring).
But this bug was something we've been keeping our eye on, especially it's a useful signal to us to see an issue with high "Me too!" scores. Thanks all who voted on this issue, added feedback, helped us understand the problem, and... well, waited for the fix to land.
For those affected by this, I hope you'll check it out whenever it hits canary (or stable), and I'll keep an eye out for further XML issues. Please let us know if we somehow missed a <merge> case, if the feature could still be improved, or if there are any other XML tag errors you all notice.
Thanks,
David
To everyone who waited patiently on this bug, and for any (probably almost all) of you who surely gave up hope that this would ever get fixed, I'm sorry it took this long.
For a bit of context in case you are curious: I started working with a small team on an effort to improve data binding as part of the project marble initiative (
But this bug was something we've been keeping our eye on, especially it's a useful signal to us to see an issue with high "Me too!" scores. Thanks all who voted on this issue, added feedback, helped us understand the problem, and... well, waited for the fix to land.
For those affected by this, I hope you'll check it out whenever it hits canary (or stable), and I'll keep an eye out for further XML issues. Please let us know if we somehow missed a <merge> case, if the feature could still be improved, or if there are any other XML tag errors you all notice.
Thanks,
David
br...@gmail.com <br...@gmail.com> #21
We love you David!!! :D
da...@google.com <da...@google.com> #22
Aw, shucks! Appreciate it, and thanks again for understanding!
pe...@gmail.com <pe...@gmail.com> #23
has the fix been shipped yet?
as of version:
Android Studio 3.4.2
Build #AI-183.6156.11.34.5692245, built on June 27, 2019
JRE: 1.8.0_152-release-1343-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
I'm still running into this problem...
as of version:
Android Studio 3.4.2
Build #AI-183.6156.11.34.5692245, built on June 27, 2019
JRE: 1.8.0_152-release-1343-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
I'm still running into this problem...
da...@google.com <da...@google.com> #24
Fixed in 3.5 -- if you have a chance, please check out our latest RC and let me know if it works for you there. Thanks!
Description
If you use data binding and <merge> as the root tag of your layout, Android Studio will show a warning and autocomplete does not work in the XML.
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="
<merge>
some stuff here
</merge>
</layout>
I believe this is a valid use case as even the documentation has some examples like this (
Or do I miss something ?
I'm using android studio 2.4 preview 3