Home > Software design >  Is it possible to change device based build.gradle library?
Is it possible to change device based build.gradle library?

Time:10-22

Due to a bug I want to use glide library version 11 on some devices and version 10 on others. I don't know if I can find out what device is and change it in build.gradle.

 if(deviceName.equals(Huawei)){
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
 }
 else{
    implementation 'com.github.bumptech.glide:glide:4.10.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
 }

CodePudding user response:

The build process happens long before the device manufacturer is known, so this type of logic is not possible.

What you need is runtime logic to handle this type of problem. In order to manage this you'd need to have separate modules in a project, one which depends on glide 10 and another on glide 11. Then as the device runs the app, you can then determine which version to use. This is an entirely over engineered solution and I wouldn't propose it as advisable.

  • Related