0

Main project A (APK) depends on sub-project B (AAR). Both A and B depend on C (AAR). The problem is C included twice which cause:

"values.xml:XXX: error: Attribute "YYY" has already been defined"

How would I exclude transient dependency C from final APK?

Project A:

android_binary (
  deps = [    
    ':src',
  ], ...
)

android_library(
  name = 'src',
  deps = [
  ':C',
  '//B:src',    
  '//B:res',
  ], ...
}

android_resource(
  name = 'res',
  res = 'src/main/res', ...
}

Sub-project B

android_aar (
  deps = [
    ':src',
    ':res'
  ], ...
)

android_library(
  name = 'src',
  deps = [
    ':res',
    ':C'
  ], ...
)

android_resource(
  name = 'res',
  deps = [
    ':C'
  ], ...
)

C is "appcompat-v7.aar".
Note: A contains C in "A/libs" and B contains C in "B/libs".

surlac
  • 2,961
  • 2
  • 22
  • 31

2 Answers2

0

I ended up removing dependency C from main project A while I'm working on sub-project B.
This way A gets C through sub-project B as a transitive dependency and prevents C to be included twice.

surlac
  • 2,961
  • 2
  • 22
  • 31
0

It's hard to tell from the sample you provided, but it sounds like you have 'C' defined twice: once in A/libs and once in B/libs. Because of this Buck doesn't understand it's "the same thing". What you should do is put 'C' in a location where both A and B can reference it (having a 'third-party' folder that is a peer to 'A' and 'B' is pretty common), that way Buck will be able to see that there is a dependency diamond in the graph and resolve that correctly.

marcin.kosiba
  • 3,221
  • 14
  • 19