【问题标题】:android studio 2.2 preview app cannot recognize library dependenciesandroid studio 2.2 预览版应用程序无法识别库依赖项
【发布时间】:2016-06-05 12:48:52
【问题描述】:

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

库构建.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 时。这个问题消失了。 那么有人可以帮助我吗?有什么问题。

谢谢!

【问题讨论】:

  • 尝试在您的settings.gradle 文件中添加include ':library',假设您还没有它。
  • @leeo 你把问题卖了吗?我也遇到过这种情况
  • 我也有类似的问题。我的 2 个依赖库中有 jar 文件,它们被主应用程序忽略。

标签: android dependencies android-studio-2.2


【解决方案1】:

这可能是传递依赖的问题,将 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}
}

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-18
    • 1970-01-01
    • 2021-04-16
    • 2016-11-05
    相关资源
    最近更新 更多