Androidx and databinding

rekire picture rekire · Jul 21, 2018 · Viewed 12.8k times · Source

I'm migrating my dependencies for an Android P test to the androidx dependencies. For some not very clear reasons my project does not compile anymore (and no I won't provide the details to avoid a distinct problem). I found out (via gradlew dependencies) that the databinding uses the "oldschool" dependency android.arch.lifecycle:runtime:1.0.3 instead of androidx.lifecycle:lifecycle-runtime:2.0.0-beta01. I guess that could be one reason.

Any idea how to force using the new package names/dependencies?

Answer

Philipp Hofmann picture Philipp Hofmann · Apr 12, 2019

Enabling AndroidX in the gradle.properties fixed this problem for me:

android.useAndroidX=true
android.enableJetifier=true

See https://developer.android.com/jetpack/androidx#using_androidx:

android.useAndroidX: When set to true, the Android plugin uses the appropriate AndroidX library instead of a Support Library. The flag is false by default if it is not specified.
android.enableJetifier: When set to true, the Android plugin automatically migrates existing third-party libraries to use AndroidX by rewriting their binaries. The flag is false by default if it is not specified.