AJit
AJit

Reputation: 1303

AndroidX Error: Both old and new data binding packages are available in dependencies

I have already updated gradle.properties file adding:

android.useAndroidX=true
android.enableJetifier=true

But i have this error:

e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: failure, see logs for details.
AndroidX Error: Both old and new data binding packages are available in dependencies. Make sure you've setup jettifier  for any data binding dependencies and also set android.useAndroidx in your gradle.properties file.
    at android.databinding.tool.util.L.printMessage(L.java:134)
    at android.databinding.tool.util.L.e(L.java:107)
    at android.databinding.tool.Context.discoverAndroidX(Context.kt:62)

Upvotes: 8

Views: 1860

Answers (6)

Khaled Abdrabo
Khaled Abdrabo

Reputation: 21

I had the same error and it got resolved when I removed this line (implementation 'androidx.databinding:databinding-compiler:3.6.0') from my dependencies in app/build.gradle. Hope this helps

Upvotes: 0

gor
gor

Reputation: 1056

in my case i just removed implementation 'androidx.databinding:databinding-compiler:3.5.3'

Upvotes: 0

Martin Zeitler
Martin Zeitler

Reputation: 76779

When this happens after migrating... just delete the build directories, which hold the generated sources (even if all of the artifacts had been replaced in the build.gradle, the generated data-bindings may still be present in these sources - causing that duplicate warning).

Upvotes: 0

Jorgesys
Jorgesys

Reputation: 126523

Even if you enable the use of AndroidX

android.useAndroidX=true
android.enableJetifier=true

and databinding

android {
    ...
    ...
    dataBinding {
        enabled = true
    }

}

you will still have problems related to dependencies.

I suggest to you, refactoring and changing automatically all the necessary imports to Android X to avoid this kind of problems.

Select your project, go yo Refactor > Migrate to AndroidX

enter image description here

Upvotes: 3

Anubhav Malik
Anubhav Malik

Reputation: 241

android.databinding.enableV2=true

add this line to your gradle.properties file.

Also, snippet of your build.gradle (app) file would be much helpful.

Upvotes: 0

Khemraj Sharma
Khemraj Sharma

Reputation: 58984

AndroidX Error: Both old and new data binding packages are available in dependencies.

This error means that you have not yet converted all your old dependencies to their new respective dependency.

This official page has a list of artifact mappings. You need to identify your old dependencies and change it to new as mapped in above page.

For example -

com.android.support:cardview-v7 is available in androidx.cardview:cardview:1.0.0 com.android.support:support-v4 - androidx.legacy:legacy-support-v4:1.0.0

once you change all dependencies to new artifacts then your error will resolve. If you need to know about AndroidX, here is an detailed answer.

Upvotes: 0

Related Questions