Search code examples
androidbuildmulti-projecttransitive-dependencybuck

Buck: transitive dependencies


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".


Solution

  • 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.