2

In our library module, we have resource files that unfortunately have the same name as support library files: such as abc_list_focused_holo.9.png (It's not my decision and I am not allowed to rename it.)

Now, I am trying to add Goole Play Service. So I added

compile 'com.google.android.gms:play-services:7.5.0'

I got this error:

:Bad-Project:processReleaseResourcesC:\Bad-Project\build\intermediates\res\release\drawable-hdpi-v4\abc_list_focused_holo.9.png: error: Duplicate file.
C:\Bad-Project\build\intermediates\res\release\drawable-hdpi\abc_list_focused_holo.9.png: Original is here. The version qualifier may be implied.
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Bad-Project:processReleaseResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\xxx\AppData\Local\Android\sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1

I have tried adding

packagingOptions {
    pickFirst 'res/drawable-hdpi-v4/abc_list_focused_holo.9.png'
    pickFirst 'res/drawable-hdpi/abc_list_focused_holo.9.png'
}

And also

packagingOptions {
    exclude 'res/drawable-hdpi-v4/abc_list_focused_holo.9.png'
    exclude 'res/drawable-hdpi/abc_list_focused_holo.9.png'
}

However, they didn't work. I still have the same error. Any idea how can I fix this issue?

Thanks

pt2121
  • 11,720
  • 8
  • 52
  • 69
  • 1
    I'd start by not adding that particular artifact, but instead go with a finer-grained dependency if you can. See the "Selectively compiling APIs into your executable" section in [the Play Services setup documentation](https://developers.google.com/android/guides/setup). It is possible that you can bypass the problem (and shrink your APK as a nice fringe benefit). Beyond that, though, your problem does not make a lot of sense, as you're supposed to be able to override a library's resources at the app level. – CommonsWare Aug 05 '15 at 19:51
  • Though, based on the Googly comments on [this issue](https://code.google.com/p/android/issues/detail?id=176252), the answer may be for you to move this resource in your project from `res/drawable-hdpi/` to `res/drawable-hdpi-v4/` and see if that helps. – CommonsWare Aug 05 '15 at 19:55
  • @CommonsWare thanks. That's very useful information. I'll try that. Btw, Do you know where I can find extensive info about resource merging process? – pt2121 Aug 05 '15 at 19:58
  • I am aware of "your problem does not make a lot of sense, as you're supposed to be able to override a library's resources at the app level." but I can't figure out why this issue happens. Thanks again. – pt2121 Aug 05 '15 at 20:00
  • 1
    "Do you know where I can find extensive info about resource merging process?" -- ummm... try "Being John Malkovich" with one of the Android tools team members? :-) I mean, there's a pinch [of documentation](http://tools.android.com/tech-docs/new-build-system/resource-merging), but beyond that, there's not a lot that I can point you towards. – CommonsWare Aug 05 '15 at 20:01
  • @CommonsWare using finer-grained dependency bypasses my issue. Thanks a lot. really appreciated! – pt2121 Aug 05 '15 at 20:04

0 Answers0