0

I have a project using an old version of google play services that I need to keep otherwise it would need to be heavily rewritten. Now I have added a new library that uses a newer version of google play services and I get a duplicate class error.

How can I force android studio to use the newer version of google play services in the library for the library but also be able to use the older version in my app?

kkl260
  • 375
  • 2
  • 17

1 Answers1

1

Unfortunately, this isn't possible. The classes for your app and the library are combined to form your APK, so you can only have one version of a given library. You could force it to use one of the two versions (for example, something like this), but based on your statement that it would need to be extensively rewritten, I assume that the two versions are not API compatible.

There are utilities like Jar Jar Links that can solve this in some cases, but (especially based on the embedded proguard rules, which reference classes found via reflection) I'd be surprised if it worked in the case of something as complex as Google Play Services, which is likely depending on its class names remaining unchanged.

Ryan M
  • 18,333
  • 31
  • 67
  • 74