带有gradle的Android工作室,如何依赖传递?

时间:2015-12-03 04:01:41

标签: android gradle

在android studio中,我的app模块依赖com.android.support:support-v4:21.0.+ 和依赖一个库模块(lib-menu),它也依赖com.android.support:support-v4:21.0。+

那么,如何在app的build.gradle和lib-menu的build.gradle中编写依赖项? 我想知道依赖关系是如何传递的。

以下是我的build.gradle,它会导致一些错误吗?

app的build.gradle:

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   compile project(':lib-menu')
   compile 'com.android.support:support-v4:21.0.+'
}

lib-menu' build.gradle:

dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')
  compile 'com.android.support:support-v4:21.0.+'
}

1 个答案:

答案 0 :(得分:0)

这不会导致任何错误,但您可以尝试使用提供的依赖

dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')
  provided 'com.android.support:support-v4:21.0.+'
}