Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlinx synthetic and AndroidX

After migrating to AndroidX I found that in some, not all of my classes the kotlinx.android.synthetic fields are now failing to convert to the actual class.

Widget has an unresolved type 'androidx.core.widget.DrawerLayout', and thus it was upcasted to 'android.view.View'

Is kotlinx.android.synthetic currently incompatible with AndroidX?

like image 334
Anthony Avatar asked Aug 29 '18 14:08

Anthony


People also ask

Why is kotlin synthetics deprecated?

Synthetic properties to access views were created as a way to eliminate the common boilerplate of findViewById calls. These synthetics are provided by JetBrains in the Kotlin Android Extensions Gradle plugin (not to be confused with Android KTX).

Is Viewbinding deprecated?

Kotlin Android Extensions is deprecated, which means that using Kotlin synthetics for view binding is no longer supported.

Is findViewById deprecated?

findViewById. Recently Android has announced that with Kotlin 1.4. 20, their Android Kotlin Extensions Gradle plugin will be deprecated and will no longer be shipped in the future Kotlin releases.


1 Answers

I'm using androidx with kotlinx.android.synthetic and a drawer layout with no issues. I believe the drawer layout tag should be androidx.drawerlayout.widget.DrawerLayout.

like image 111
tgrable Avatar answered Oct 10 '22 21:10

tgrable