Groupie: unresolved supertypes: kotlinx.android.extensions.LayoutContainer

Created on 21 Dec 2017  路  3Comments  路  Source: lisawray/groupie

I'm trying to use this lib in my project but I cannot get started.
I want to use the kotlin-extensions but it does not compile - showing the following error:

Error:Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class com.xwray.groupie.kotlinandroidextensions.ViewHolder, unresolved supertypes: kotlinx.android.extensions.LayoutContainer

I've created a demo-project with each step to reproduce in one commit (just 4):
https://github.com/hardysim/groupie-demo


There are multiple confusing parts in the README.md here when trying to get started:

  • it seems like one need to add the extensions-part of the lib as well, which is not documented

    • implementation 'com.xwray:groupie-kotlin-android-extensions:2.0.0-beta1'

  • the whole "Kotlin"-section seems unnecessary

    • kotlin-android-extensions used to work out of the box by just using an import to kotlinx.android.synthetic.main [...]

    • because it does not work for now, maybe it is needed but even when adding all this to my project it does not work either


How can I set this lib up to work with kotlin (and the nice extensions for the view)?

Most helpful comment

Done! In the latest (Kotlin 1.2.10) you still need the experimental flag. I updated the README. Happy New Year :)

All 3 comments

Looks like it works just fine when adding the following to the app's build.gradle:

androidExtensions {
    experimental = true
}

I've updated my demo-project with it and it seems to work now (https://github.com/hardysim/groupie-demo/commit/8ae9d7ae9182cfa6d2616689d54f4c73ae38184e).


With this, it really looks like you do not need to include the stuff for the app's build.gradle mentioned here https://github.com/lisawray/groupie#kotlin but you need to do the following instead:

  • include implementation 'com.xwray:groupie-kotlin-android-extensions:2.0.0-beta1'
  • add the experimental-flag I mentioned above

To sum this up:

  • Would you please update the install-guide in README.md for others stumbling over this?
  • What does this experimental-flag do? Is it safe to keep it?

Hey @hardysim ! Yes, I've just come on to make a stable 2.0 build and I will update the README.

You're actually using a build I published (beta1) but didn't have time to update the docs. You may notice they still point to alpha1 for this reason because I didn't want anyone to get confused as you had. I'm really glad you figured it out.

The experimental flag enables layout caching using Kotlin Android extensions in classes which are not fragments or activities, using the LayoutContainer class. This is very important for RecyclerView and it's a distinction i missed when I first added Kotlin support. It's possible it's in the main Kotlin project by now as they are moving so fast -- I'm about to check!

Done! In the latest (Kotlin 1.2.10) you still need the experimental flag. I updated the README. Happy New Year :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ValCanBuild picture ValCanBuild  路  5Comments

amervelic picture amervelic  路  3Comments

Nimrodda picture Nimrodda  路  3Comments

rpedretti picture rpedretti  路  3Comments

jordond picture jordond  路  6Comments