When I try to import the List class type into an xml file using Android Data Binding I receive the following error
Error: cannot find type element for List.
This error is really frustrating because I followed this documentation and it doesn't appear to be correct. Although there are quite a lot of data binding tutorials online, I can't manage to find one which covers this particular issue.
The data section in my xml file looks as follows:
<data>
<import type="android.view.View" />
<import type="java.util.List" />
<import type="com.example.app.Book" />
<variable
name="books"
type="List<Book>" />
</data>
List<Book> books = new ArrayList<>();
mBinding.setBooks(books);
Has anyone managed to solve this issue? I would really appreciate some help here.
I met the problem just now,
Error:(34, 26) cannot find type element for List
and solved it by replacing
<data>
<import type="java.util.List"/>
<variable
name="list"
type="List<String>"/>
</data>
with
<data>
<variable
name="list"
type="java.util.List<String>"/>
</data>
Hope this can help you!
Besides, try to reference type with full qualified class name instead of short class name. Like
type="java.util.List<com.example.app.Book>"
because in my case, I found the import tag does not make any sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With