I have an Android project that has been migrated to AndroidX. At some point, I want to add a new library. This library is using a support library with data binding.
I have enabled Android Jetifier in my gradle.properties. I am using Android Gradle build tool v.3.3.2 and Gradle v.4.10.1.
Here is my gradle.properties:
org.gradle.jvmargs=-Xmx1536m
kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true
Here is my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.test"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled = true
}
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '28.0.0'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation <library with AndroidX and data binding>
}
I got the following error on compile time.
Task :app:compileDebugJavaWithJavac FAILED
GallerypickerBinding.java:22: error: package android.support.constraint does not exist
private final android.support.constraint.ConstraintLayout mboundView0;
GallerypickerBinding
is the generated class from data binding of the newly added library.
When I checked this file, it uses androidx.databinding.ViewDataBinding
from AndroidX, but in the same file, it still uses android.support.constraint.ConstraintLayout
from support library.
I expect Android Jetifier to convert all support libraries including to AndroidX, but it seems like it fails to convert the ConstraintLayout generated from data binding to AndroidX.