Transitive dependencies problem

Hello.
I have a library .aar that I’m trying to include in my project.
I can compile but at run time the app crashes because the aar has some transitive dependencies (like dagger). I looked at the source code of the projects that generates this aar and the gradle script looks like this:

dependencies {

api 'org.eclipse.jetty:jetty-server:8.1.12.v20130726'
api 'org.eclipse.jetty:jetty-servlet:8.1.12.v20130726'
api 'org.eclipse.jetty:jetty-client:8.1.12.v20130726'
api 'org.slf4j:slf4j-jdk14:1.7.5'

api fileTree(include: ['*.jar'], dir: 'libs')
api 'com.squareup:otto:1.3.8'
api 'com.squareup.picasso:picasso:2.5.2'
api files('libs/netty.jar')
api files('libs/cling-support-2.1.1.jar')
api files('libs/cling-core-2.1.1.jar')
api files('libs/seamless-http-1.1.1.jar')
api files('libs/seamless-util-1.1.1.jar')
api files('libs/seamless-xml-1.1.1.jar')
api 'commons-io:commons-io:2.4'
api 'org.apache.commons:commons-lang3:3.4'
api files('libs/login-with-amazon-sdk.jar')
api 'androidx.palette:palette:1.0.0'
api 'com.kyleduo.switchbutton:library:1.2.9'

api 'com.squareup.retrofit:retrofit:1.9.0'
api 'com.squareup.okhttp:logging-interceptor:2.6.0'
//    implementation project(':cutekit')
api 'androidx.multidex:multidex:2.0.1'
api 'com.google.android.material:material:1.1.0'
api 'androidx.cardview:cardview:1.0.0'
api 'androidx.recyclerview:recyclerview:1.1.0'

// location play services
api 'com.google.android.gms:play-services-location:17.0.0'

// dexter runtime permissions
api 'com.karumi:dexter:4.2.0'

api 'androidx.appcompat:appcompat:1.1.0'
api 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.core:core-ktx:1.3.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

api 'com.android.volley:volley:1.1.1'

api 'com.github.zcweng:switch-button:0.0.3@aar'

api 'androidx.constraintlayout:constraintlayout:1.1.3'

//sdk
implementation project(path:':sdk_release:source')

//dependency added to implement idtm sdk
//rxjava
api 'io.reactivex.rxjava2:rxjava:2.1.0'
api 'io.reactivex.rxjava2:rxandroid:2.0.1'

//airbnb lotte animation
api 'com.airbnb.android:lottie:3.4.4'


//dagger
implementation 'com.google.dagger:dagger-android:2.20'
implementation 'com.google.dagger:dagger-android-support:2.20' // if you use 
annotationProcessor 'com.google.dagger:dagger-android-processor:2.20'
annotationProcessor 'com.google.dagger:dagger-compiler:2.20'

//retrofit
implementation 'com.squareup.okhttp3:okhttp:4.2.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.1'
implementation 'com.squareup.retrofit2:converter-gson:2.7.0'

//firebase
implementation 'com.google.firebase:firebase-core:17.2.1'

//utils
implementation 'com.google.guava:guava:29.0-jre'

implementation 'com.github.danimahardhika:cafebar:1.3.1'

def work_version = "2.4.0"

// (Java only)
implementation "androidx.work:work-runtime:$work_version"

}

I don’t know how to fix runtime issues with my configuration.
My new module containing this aar is this:

configurations.maybeCreate(“default”)
artifacts.add(“default”, file(‘security.aar’))

In the modules where I need to use this aar I do this:

implementation project(path: ‘:security.aar’)

I chose the module approach because I thought it was possible to put all the dependencies of the security.aar in his own module because the app gradle file has already a lot of dependencies and I don’t want to keep on adding stuff in it. MAybe there is a cleaner and simpler wayt to achieve this? I’m exahusted.

Regards.
Paolo

1 Like