Search code examples
androidandroidxaar

cannot use Arr library in project build with androidx


I have migrated my project to androidx. my project depends on some third party libraries, i'm using one arr file in my project. after migration, i'm getting error like below.

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

here is app level gradle file

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


can anyone help me on this?


Solution

  • Try clearing your gradle caches which should be stored here: C:\Users\<username>\.gradle\caches\transforms-1, and then rebuild the project.

    Edit:

    Change your dependencies in build.gradle to use AndroidX namespace:

    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'