0

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?

imran khan
  • 382
  • 3
  • 15

2 Answers2

0

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'
Ernest Zamelczyk
  • 2,562
  • 2
  • 18
  • 32
  • yes, i have tried this. but not working. it seems that issue occurred because arr is not built using androidx. – imran khan Oct 01 '19 at 09:26
  • Yes but that's what Jetify is for. It should transform your aar to AndroidX namespace automatically. I'm 90% sure it's related to caches. Try clearing everything and invalidating caches from inside Android Studio. – Ernest Zamelczyk Oct 01 '19 at 09:33
  • Hi, I have removed transform-1 folder, then set android.enableJetifier=false in gradle.properties file, then able to build project successfully. but getting error Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.1.0] AndroidManifest.xml:24:18-86 is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory). if revert to android.enableJetifier=true, then getting same old issue – imran khan Oct 01 '19 at 10:44
  • I already migrated all to androidx name space, it seems i have uploaded outdated gradle build file here when i revert androidx migration. thanks for pointing out – imran khan Oct 01 '19 at 11:55
  • by deleting C:\Users\\.gradle\caches\transforms-1 and rebuilding project it worked but i got another problem regarding manifest merge – imran khan Oct 02 '19 at 03:44
0

After migrating into Android X, you need to do some steps to clear all the un-used imports.

To clear all those un-used imports :-

Right click on src:- You will get an option "Optimise imports" Once you are done with this optimisation. Check it out all the changes in github.

If still you are getting same issue. Close the project. Re-import the project again.

Shyak Das
  • 119
  • 1
  • 5
  • I also faced same issue. But I follow this steps :- 1. Clone the project again. 2. Open Android Studio. 3 There is one option "Import project" import it again.. – Shyak Das Oct 01 '19 at 09:50