Relative Gradle project dependency with HoloEveryw

2019-02-23 08:52发布

问题:

I have this directory structure:

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

My settings.gradle looks like this

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 depends on contrib:holo-everywhere:library.

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

contrib:holo-everywhere:library is built successfully and when contrib:holo-everywhere:addons:preferences is being built I get some unclear error.

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

I kind of get the feeling that the problem is here:

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

Is this the correct way to define dependency?

Update: Adding holo-everywhere build.gradle content.

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'

回答1:

Some people have reported a similar problem when using a version number in the allprojects section with the android-plugin. Could be a bug in that plugin. Try removing the version to see if it changes anything.



回答2:

This setting works with gradle 2.2.1 but not with androidstudio 1.0.2 (yet)

project/settings.gradle (define which modules belong to the project) :

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'

if you want to use contrib/holo-everywhere/library in project/app-one/build.gradle

replace

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

with

dependencies {
  compile project('library')
}

You can test this with

cd \path\to\Project
gradlew --gui

Unfortunately this does not work in settings.gradle (with gradle 2.2.1)

include '../commonLibraries/mylib'

AndroidStudio-gui and gradle-gui can interprete but not compile this

project/settings.gradle (define which modules belong to the project) :

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

dependencies {
  compile project('library')
  compile project('library')
  compile project('preferences')
  compile project('slider')
  compile project('app-library')
}


回答3:

I had the same problem in my project, I solved when I realize that my AAR files weren't inside the folder they should be. So I added the missing AAR files to their respective folders.

While switching branches, the AAR files were not ignored, so I was trying to gradlew build the project with no success.