Android:如何在 Settings.gradle 中包含项目

标签 android gradle android-gradle-plugin

按照我的项目目录结构:

dev/
   android/
           apps/ 
                project2
   project1

我想将项目 1 包含在我的项目 2 中。因此我尝试将此项目添加到我的 settings.gradle 文件中。以下是我的settings.gradle文件的内容:

include ‘:project2', ‘dev:project1'
project('../../..project1').projectDir = new File(settingsDir, ‘:project1’)

build.gradle 文件:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project('../client/project1')
}

当我尝试构建项目时,出现以下错误:

Error:Project with path '../../.. project1' could not be found.

最佳答案

我通过在settings.gradle中使用以下代码解决了这个问题

include ‘:project2', ‘dev:project1'
project(':project1').projectDir = new File(settingsDir, ‘../../../project1’)

构建.gradle

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

关于Android:如何在 Settings.gradle 中包含项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31684371/

相关文章:

使用 Gradle 和 ProGuard 构建 Android : "The output jar must be specified after an input jar, or it will be empty"

java - 找不到 transform-api.jar

android - 基于旋转的 Sprite 运动

android - 禁用特定版本,例如 Honeycomb/3.1

intellij-idea - build.gradle 文件中的 IntelliJ 运行配置

Java 11/IntelliJ : Module not found

android - 构建新的 APK 版本时,新的更改不适用

python - Android 应用程序与 Python 后端之间的通信

android - 如何将 Dagger 2 与自定义 View 一起使用?

java - 如何在 Gradle 项目中使用 IntelliJ IDEA 生成一个包含 javadoc 的 .jar?