Multiple versions of the same library

I need to include two versions of the same library at the same time in the same project.

I found a solution from nine years ago, but it doesn’t seem to be working for me:

I’ve tried:

configurations {
    apiv1
    apiv1alpha
}

dependencies {
    apiv1 'com.google.apis:google-api-services-firebaseappdistribution:v1-rev20230808-2.0.0'
    apiv1alpha 'com.google.apis:google-api-services-firebaseappdistribution:v1alpha-rev20231221-2.0.0'
}

task libs(type: Sync) {
    from configurations.apiv1
    from configurations.apiv1alpha
    into "$buildDir/libs"
}

But either I didn’t understand the previous answer or something has changed in the last decade - or both.

Any suggestion what I should try?

Besides that this setup is not really bad-practice free, as the configurations that are created there have a legacy setup that should better not be used, currently it should work fine. What makes you think it does now work?

Indeed it works.

I (wrongly) assumed that gradle would automatically pick up dependencies on the jar files in the libs directory. Once I add these jars as explicit dependencies I can use the code contained in them.

1 Like