2

My Android project has 2 Android library modules: app and boo. app module has already migrated to AndroidX, boo is still using support library.

In boo module, I want to add a new library that depends on both support library and uses data binding.

I have enable Android Jetifier in my gradle.properties. I am using Android Gradle build tool v.3.3.2 and Gradle v.5.3.1.

Here is my gradle.properies

org.gradle.jvmargs=-Xmx1536m
kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true

My app's build.gradle that use AndroidX.

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.example"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dataBinding {
        enabled = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
nit:4.12'
    implementation project(':boo')
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.appcompat:appcompat:1.0.2'
}

My boo's build.gradle. The module depends on a library that uses both databinding and support library.

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 28

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    dataBinding {
        enabled = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }


}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation <library with support library and data binding>

databinding/LayoutWallBinding.java:13: error: cannot find symbol
    public final android.support.constraint.ConstraintLayout orderingLayout;
                                           ^
  symbol:   class ConstraintLayout
  location: package android.support.constraint

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':editor:kaptDebugKotlin'.

I expect Android Jetifier to convert all support libraries including to AndroidX, but it seems like it cannot convert the ConstraintLayout generated from data binding to AndroidX.

Chayanin Wong
  • 331
  • 2
  • 11

2 Answers2

1

No,it's not working like that If you want to use AndroidX then it's mandatory that you use all libraries of AndroidX not Support libs so Instead of this:

implementation'com.android.support.constraint:constraintlayout:1.1.3'

Use this:

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Mehul Kabaria
  • 6,404
  • 4
  • 25
  • 50
Richa Shah
  • 930
  • 3
  • 12
  • 27
  • The same goes for MultiDex and RecyclerView in this case. All your dependencies must point to AndroidX instead of support library. Jetifier only converts third-party library dependencies. Where you can you must fix the dependencies yourself (in your projects). You can go to Main Menu > Refactor > Migrate to AndroidX. – Eugen Pechanec Apr 01 '19 at 05:31
-1

Convert your library to androidX using standalone jetifier and see if it helps.

./jetifier-standalone -i libraryToProcess.aar -o result.aar
Miroslav Glamuzina
  • 4,472
  • 2
  • 19
  • 33
Ranjan Kumar
  • 1,164
  • 7
  • 12