Getting “more than one library with package name 'com.google.android.gms'” when running wear module

前端 未结 1 837
北恋
北恋 2021-01-23 11:35

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:<

相关标签:
1条回答
  • 2021-01-23 11:39

    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.

    0 讨论(0)
提交回复
热议问题