Friday, 20 July 2018

Can I preserve older versions of library used by a dependency?

I have an Android project where Glide v4 is one of its dependency.
This project has another dependency, let's call it dependency A , where it depends on Glide v3 instead.
I don't know if it matters, but dependency A can only be included as an aar.
So this is part of my build.gradle:
implementation(name: 'dependency_a', ext: 'aar')
implementation ("com.github.bumptech.glide:glide:4.7.1") {
    exclude group: "com.android.support"
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'

The app can be compiled; but when code in dependency A runs that uses Glide v3:
Glide.with(context).load(imageUrl).asBitmap().into(new SimpleTarget<Bitmap>() {...}

The app crashes with this message:
java.lang.NoSuchMethodError: No virtual method load(Ljava/lang/String;)Lcom/bumptech/
glide/DrawableTypeRequest; in class Lcom/bumptech/glide/RequestManager; or its super 
classes (declaration of 'com.bumptech.glide.RequestManager' appears in /data/app/{my.package.
name}}-LItMzBkBqXw3lyYYdKp-SA==/base.apk:classes15.dex)

I am finding a way to preserve Glide v3 in dependency A, but still use Glide v4 for my app and other dependencies.
Is it even possible?

Why don't I simply use Glide v3 for my app as well

This is because another dependency B needs me to use Glide v4.


from Can I preserve older versions of library used by a dependency?

No comments:

Post a Comment