I'm adding a wear module to an app. (using this sample code as a reference)
So I have 3 modules, each one depends on a version of com.google.android.gms:play-services:
- app - compile 'com.google.android.gms:play-services:6.1.11'
- wear - 'com.google.android.gms:play-services-wearable:6.5.+'
- shared - compile 'com.google.android.gms:play-services:6.1.11'
When compiling the Wear module, I get this error:
Error:Execution failed for task ':wear:processDebugResources'.
Error: more than one library with package name 'com.google.android.gms'
You can temporarily disable this error with android.enforceUniquePackageName=false
However, this is temporary and will be enforced in 1.0
Obviously, if I change play-services-wearable play-services in the wear module's build.gradle, everything works fine, however from what I understand, play-services-wearable is a light-weight version of play-services.
Is there a way, considering my app's structure, to use play-services-wearable in my wear module?
The issue is more that you have multiple different versions of Google Play Services being used within the same app (version 6.1 and version 6.5). You can update your shared (and app) modules to use compile 'com.google.android.gms:play-services:6.5.+
and then you'll only have one version of Google Play Services and avoid the issue you are facing.
In your case, you only need to define Google Play Services in the shared module - assuming your app and wear modules both have a dependency on it, they'll automatically inherit any dependencies so redeclaring them is unnecessary (although it doesn't harm things if you prefer to do it anyways).
Note: the play-services-wearable
library is one of the many split libraries available in Google Play Services 6.5 - these do indeed allow you to only include the parts of Google Play Services you need in your application. In almost all cases, you should consider moving to explicitly depending on only the parts of Google Play Services rather than using com.google.android.gms:play-services
in its entirety: by including the entire com.google.android.gms:play-services
even once you pull in all of Google Play services even if later you declare or use a single portion of the library.