首页 > 解决方案 > 无法在使用 androidx 的项目构建中使用 Arr 库

问题描述

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

无法解析“:app@debug/compileClasspath”的依赖关系:无法使用转换 JetifyTransform 转换文件“csjsdk-beta.aar”以匹配属性 {artifactType=processed-aar} 显示详细信息 受影响的模块: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'
}


谁可以帮我这个事?

标签: androidandroidxaar

解决方案


尝试清除应该存储在此处的 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'

推荐阅读