在 gradle 中使用 Play 服务时已定义属性 "theme"
Attribute "theme" has already been defined when using Play Services in gradle
在我的 build.gradle 文件中使用依赖项时:
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
我遇到错误:
Attribute \"theme\" has already been defined
在我的 colors.xml 中。如果我将依赖项更改为
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
它似乎有效 - 我没有收到错误。但我不想包括完整的播放服务,我只想要定位服务。
为什么我只包含定位服务时会收到此错误,我该如何解决?
注意:我知道关于此的现有问题,但答案是仅使用 "latest" 版本并指的是播放服务 6.x.我正在使用 play services 7.5 并收到错误,所以这是不同的。
经过大量猜测和失败的反复试验后,我发现我对 segment.io 的旧依赖包括 Play Services 库,现在它包括了旧库的完整版本,因为我没有。
问题是 Google 钱包。我发现在 Wallet 的 attrs.xml 中定义了一个属性“theme”。定义一个名为“theme”的属性并不是最好的主意,因为 AppCompat 库必须使用它来替换 Android 系统主题属性。所以这个文件有问题:
build\intermediates\exploded-aar\com.google.android.gms\play-services.0.89\res\values\wallet-attrs.xml
我通过替换此解决了问题:
compile('io.segment.analytics.android:all:1.4.4@aar')
有了这个:
compile('com.segment.analytics.android:analytics-core:3.1.3@aar')
我发布了一个完整的博客 post 关于这个权利 here on my blog。
在我的 build.gradle 文件中使用依赖项时:
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
我遇到错误:
Attribute \"theme\" has already been defined
在我的 colors.xml 中。如果我将依赖项更改为
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
它似乎有效 - 我没有收到错误。但我不想包括完整的播放服务,我只想要定位服务。
为什么我只包含定位服务时会收到此错误,我该如何解决?
注意:我知道关于此的现有问题,但答案是仅使用 "latest" 版本并指的是播放服务 6.x.我正在使用 play services 7.5 并收到错误,所以这是不同的。
经过大量猜测和失败的反复试验后,我发现我对 segment.io 的旧依赖包括 Play Services 库,现在它包括了旧库的完整版本,因为我没有。
问题是 Google 钱包。我发现在 Wallet 的 attrs.xml 中定义了一个属性“theme”。定义一个名为“theme”的属性并不是最好的主意,因为 AppCompat 库必须使用它来替换 Android 系统主题属性。所以这个文件有问题:
build\intermediates\exploded-aar\com.google.android.gms\play-services.0.89\res\values\wallet-attrs.xml
我通过替换此解决了问题:
compile('io.segment.analytics.android:all:1.4.4@aar')
有了这个:
compile('com.segment.analytics.android:analytics-core:3.1.3@aar')
我发布了一个完整的博客 post 关于这个权利 here on my blog。