4

我有这个目录结构:

Project
    contrib/
        holo-everywhere
            library
            addons/
                slider
                preferences
    app-library
    app-one
    app-two
    settings.gradle

我的 settings.gradle 看起来像这样

include 'contrib:holo-everywhere:library'
include 'contrib:holo-everywhere:addons:preferences'
include 'contrib:holo-everywhere:addons:slider'
include 'app-library'
include 'app-one'
include 'app-two'

contrib:holo-everywhere:addons:preferences取决于contrib:holo-everywhere:library

dependencies {
  compile project(':contrib:holo-everywhere:library')
}

contrib:holo-everywhere:library已成功构建,何时contrib:holo-everywhere:addons:preferences构建我得到一些不清楚的错误。

:contrib:holo-everywhere:addons:preferences:compileLint
:contrib:holo-everywhere:addons:preferences:copyReleaseLint UP-TO-DATE
:contrib:holo-everywhere:addons:preferences:mergeReleaseProguardFiles UP-TO-DATE
:contrib:holo-everywhere:addons:preferences:packageReleaseAidl UP-TO-DATE
:contrib:holo-everywhere:addons:preferences:preBuild UP-TO-DATE
:contrib:holo-everywhere:addons:preferences:preReleaseBuild UP-TO-DATE
:contrib:holo-everywhere:addons:preferences:preDebugBuild UP-TO-DATE
:contrib:holo-everywhere:addons:preferences:preTestBuild UP-TO-DATE
:contrib:holo-everywhere:addons:preferences:prepareMdAndroidContribHoloEverywhereLibraryUnspecifiedLibrary FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':contrib:holo-everywhere:addons:preferences:prepareMdAndroidContribHoloEverywhereLibraryUnspecifiedLibrary'.
> File '/home/project/contrib/holo-everywhere/library/build/libs/library.aar' specified for property 'bundle' does not exist.

我有点感觉问题出在这里:

dependencies {
  compile project(':contrib:holo-everywhere:library')
}

这是定义依赖关系的正确方法吗?

更新:添加holo-everywhere build.gradle内容。

buildscript {
  repositories {
    mavenCentral()
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:0.5.+'
  }
}

allprojects {
  group = 'org.holoeverywhere'
  version = '2.0.0-SNAPSHOT'

  repositories {
    mavenLocal()
    mavenCentral()
    maven {
      url "https://github.com/Prototik/HoloEverywhere/raw/repo"
    }
  }

  tasks.withType(Compile) {
    options.encoding = "UTF-8"
  }
}

apply plugin: 'android-reporting'
4

3 回答 3

1

有些人使用allprojects带有android-plugin. 可能是该插件中的错误。尝试删除该版本以查看它是否会改变任何内容。

于 2013-09-22T15:25:43.907 回答
0

此设置适用于 gradle 2.2.1,但不适用于 androidstudio 1.0.2(尚未)

project/settings.gradle(定义哪些模块属于该项目):

include 'contrib/holo-everywhere/library'
include 'contrib/holo-everywhere/addons/preferences'
include 'contrib/holo-everywhere/addons/slider'
include 'app-library'
include 'app-one'
include 'app-two'

如果你想在 project/app-one/build.gradle 中使用 contrib/holo-everywhere/library

代替

dependencies {
  compile project(':contrib:holo-everywhere:library')
}

dependencies {
  compile project('library')
}

你可以用

cd \path\to\Project
gradlew --gui

不幸的是,这在 settings.gradle 中不起作用(使用 gradle 2.2.1)

include '../commonLibraries/mylib'

AndroidStudio-gui 和 gradle-gui 可以解释但不能编译

project/settings.gradle(定义哪些模块属于该项目):

include 'contrib:holo-everywhere/library'
include 'contrib:holo-everywhere/addons/preferences'
include 'contrib:holo-everywhere/addons/slider'
include 'app-library'
include 'app-one'
include 'app-two'

项目/app-one/build.gradle

dependencies {
  compile project('library')
  compile project('library')
  compile project('preferences')
  compile project('slider')
  compile project('app-library')
}
于 2015-01-09T09:45:32.153 回答
0

我在我的项目中遇到了同样的问题,当我意识到我的 AAR 文件不在它们应该在的文件夹中时,我解决了。所以我将丢失的 AAR 文件添加到它们各自的文件夹中。

在切换分支时,AAR 文件没有被忽略,所以我试图gradlew 构建项目但没有成功。

于 2018-01-18T21:52:21.083 回答