2

我的 Android 项目有 2 个 Android 库模块:appboo. app模块已经迁移到 AndroidX,boo仍在使用支持库。

boo模块中,我想添加一个既依赖于支持库又使用数据绑定的新库。

我已经在我的gradle.properties. 我正在使用 Android Gradle 构建工具 v.3.3.2 和 Gradle v.5.3.1。

这是我的 gradle.properies

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

app的使用 AndroidX 的 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.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'
}

boo的 build.gradle。该模块依赖于一个同时使用数据绑定和支持库的库。

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'.

我希望 Android Jetifier 将所有支持库转换为 AndroidX,但它似乎无法将ConstraintLayout生成的数据绑定转换为 AndroidX。

4

2 回答 2

1

不,它不是那样工作的

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

用这个:

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
于 2019-04-01T04:40:08.113 回答
-1

使用独立的 jetifier 将您的库转换为androidX,看看它是否有帮助。

./jetifier-standalone -i libraryToProcess.aar -o result.aar
于 2019-04-01T04:21:18.843 回答