Reputation: 2278
After updating to the latest gradle, I get a weird error when building the project:
[:feature_x, :feature_y] all package the same library [com.github.PhilJay:MPAndroidChart].
I have indeed added this library in both features. They are set as a dependency like:
api "com.github.PhilJay:MPAndroidChart:$rootProject.MPAndroidChart"
What is wrong with this?
Upvotes: 11
Views: 3147
Reputation: 3606
As of 2018-10, this is expected behavior, according to this issue in Google's issue tracker:
Yes, multiple non-base features depending on the same library is currently not supported because both of the features will package the library, but there's no guarantee that they'll package the same version of the library, which can lead to crashes at runtime. We opted to fail the build in these cases to prevent unexpected behavior at runtime.
Unfortunately, adding the library as a dependency to the base module is the suggested workaround for this.
Upvotes: 8