我从github克隆了一个完整的gradle项目“CompleteGradleProjA”,并将其作为子模块包含到我的本地项目中。通过“完整gradle项目”,我的意思是我可以进入目录“CompleteGradleProjA”并发出命令

cd CompleteGradleProjA && gradle build

建立它。

我的目录结构看起来像这样,
MyProj
  |---CompleteGradleProjA
  |   |---build.gradle
  |
  |---build.gradle

我的问题是:如何在不更改根目录“build.gradle”的情况下调用“CompleteGradleProjA / build.gradle”?

以下根“build.gradle”配置无济于事。
apply plugin: 'java'
dependencies {
  compile project(':CompleteGradleProjA')
}

我收到错误讯息
FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':compileJava'.
> Could not determine the dependencies of task ':compileJava'.

“CompleteGradleProjA”是一个Android项目,“CompleteGradleProjA / build.gradle”看起来像这样
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

最佳答案

CompleteGradleProjA / build.gradle

apply plugin: 'com.android.library'
// if your project isn't library then use this:
// apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '21.1.2'

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 22
    }
}

dependencies {
    compile 'com.android.support:support-v4:22.2.0' // if needed
}

settings.gradle
include ':CompleteGradleProjA'

使用apply plugin: 'com.android.library'apply plugin: 'com.android.application'代替apply plugin: 'java'

10-01 18:42