Search code examples
androidgradleandroid-gradle-plugindependenciesandroid-library

Do not duplicate dependencies


I have a library with next dependencies:

implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.2'

Now I need to add the same dependencies to the my main project with this library.

How can I implement the library so that all these dependencies are not duplicated in the main project?

Right now in my project i write:

implementation 'com.mandarine.sdk:mandarine-library:2.0.1@aar'
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'  
implementation 'com.squareup.retrofit2:retrofit:2.5.0'  
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'    
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.2'//Don't update while support Android SDK < 20

And in library:

implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.2'

Update: Also tried write in my project next:

api 'com.mandarine.sdk:mandarine-library:2.0.1@aar'

And modified my library like this:

api 'com.google.android.gms:play-services-safetynet:17.0.0'
api 'com.squareup.retrofit2:retrofit:2.5.0'
api 'com.squareup.retrofit2:converter-gson:2.5.0'
api 'com.squareup.okhttp3:logging-interceptor:3.12.2'

Unfortunately also doesn't work.


Solution

  • Resolved problem with next solution:

    implementation ('com.saltedge.sdk:saltedge-library:2.0.2@aar') {
            transitive = true
        }
    

    This helped me use dependencies in the library, and do not duplicate them in the main project.