无法在使用 androidx 构建的项目中使用 Arr 库

cannot use Arr library in project build with androidx

我已经将我的项目迁移到androidx。我的项目依赖于一些第三方库,我在我的项目中使用了一个 arr 文件。迁移后,出现如下错误。

Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform file 'csjsdk-beta.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform Show Details Affected Modules: csjsdkdemo-app

这里是应用级别 gradle 文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.demo.csjbot.csjsdkdemo"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        main {
            // 将 jniLib 指向 libs
            jniLibs.srcDir 'libs'
        }
    }

    repositories {
        flatDir {
            dirs 'libs'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "androidx.appcompat:appcompat:1.1.0"
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation(name: 'csjsdk-beta', ext: 'aar')
    implementation 'io.netty:netty-all:4.1.23.Final'
    implementation 'com.google.code.gson:gson:2.8.1'
}


谁能帮我解决这个问题?

尝试清除应存储在此处的 gradle 缓存:C:\Users\<username>\.gradle\caches\transforms-1,然后重建项目。

编辑:

更改 build.gradle 中的依赖项以使用 AndroidX 命名空间:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:1.1.0"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation(name: 'csjsdk-beta', ext: 'aar')
implementation 'io.netty:netty-all:4.1.23.Final'
implementation 'com.google.code.gson:gson:2.8.1'

迁移到 Android X 后,您需要执行一些步骤来清除所有未使用的导入。

清除所有未使用的导入:-

右键单击 src:- 您将看到一个选项 "Optimise imports" 完成此优化后。查看 github.

中的所有更改

如果您仍然遇到同样的问题。 关闭项目。再次重新导入项目。