1

我有一个带有库项目的项目,库项目中的第三个依赖项:

库构建.gradle

dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')
  compile 'com.android.support:appcompat-v7:23.2.1'
  compile 'com.android.support:design:23.2.1'
  compile 'com.android.support:support-v4:23.2.1'

  compile 'io.reactivex:rxandroid:1.1.0'
  compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
  compile 'com.jakewharton:butterknife:7.0.1'

  compile 'com.facebook.fresco:fresco:0.9.0'
  compile 'com.google.code.gson:gson:2.6.2'
  compile 'com.github.satyan:sugar:1.4'
  compile 'org.greenrobot:eventbus:3.0.0'
  compile 'com.jakewharton.timber:timber:4.1.1'

  compile 'com.android.support:multidex:1.0.1'
  testCompile 'junit:junit:4.12'
}

应用程序构建.gradle

dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')

  //compile project(':library')
  debugCompile project(path: ':library', configuration: 'debug')
  releaseCompile project(path: ':library', configuration: 'release')
}

现在我遇到了一个问题,我不能在库中使用依赖类。它无法识别这些库。

在此处输入图像描述

但是当我将依赖项放入应用程序 build.grandle 时。这个问题消失了。那么有人可以帮助我吗?有什么问题。

谢谢!

4

1 回答 1

0

这可能是传递依赖的问题,gradle 尝试将其设置为 true。

在应用程序 build.gradle 文件中

dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')

  //compile project(':library')
  debugCompile project(path: ':library', configuration: 'debug'){transitive = true}
  releaseCompile project(path: ':library', configuration: 'release'){transitive = true}
}

只是一个疯狂的猜测,完全不确定,但值得一试。

于 2016-06-05T03:46:36.407 回答