I am creating an Android app with Wear capabilities.
I want to share some code between portable and portable modules. In particular, I want to share a communication code that uses Google Play Services classes, for example. com.google.android.gms.common.api.GoogleApiClient .
The obvious way to do this is to have a module (I called it common ) and add a dependency to it in both portable and wearable modules.
Since this common module uses Play Services, I need to depend on com.google.android.gms:play-services .
I was not sure what to put the version number - the official documentation here says to use 5.0.77 , but this does not work, since the latest SDK does not have this version anywhere, instead it comes with 5.0.89 and 5.2.08 .
If I use 5.0.89 , the Wearable application does not work, with this error: Google Play services out of date. Requires 5089000 but found 5077534 Google Play services out of date. Requires 5089000 but found 5077534 . The version on the watch is older than the one I used to compile.
Instead, depending on com.google.android.gms:play-services general module could depend on com.google.android.gms:play-services-wearable , but then there is a conflict when creating, because the pocket module depends on com.google.android.gms:play-services , and these two artifacts use the same package name ( com.google.android.gms ), and therefore the gradle build fails.
What solution?
.
EDIT after discussion a bit and make my question more clear.
To be able to use the communication APIs in my common module, I have two options:
- Make
common depend on com.google.android.gms:play-services - Make
common depend on com.google.android.gms:play-services-wear
β Solution 1 does not work, because the version (5.0.89) for development is later than the version on the clock (5.0.77).
β Solution 2 does not work because the handheld module already depends on com.google.android.gms:play-services , which conflicts with com.google.android.gms:play-services-wear .