缺少多模块项目中的顶级build.gradle

phr*_*ead 18 android gradle android-studio

我错过了项目中的"顶级"项目build.gradle脚本:

在此输入图像描述

我从一个非常复杂的Maven/Eclipse项目将它导入Android Studio,它基本上在目录的顶层创建了一个模块("android"),并添加了所有子模块("tappurwear","shared"等)进入原始模块的目录.

我知道这是一种混乱的结构,但是还有很多其他构建脚本,所以我不能真正将所有文件移动到一个合适的单独模块中.

所以现在我想知道,如何为整个项目添加顶级build.gradle脚本?我见过的常见Android Studio项目只有一个,但它将我的顶级构建脚本视为"android"模块的构建脚本.我可以创建一个新的build.script作为与其他模块共享设置的顶级项目脚本吗?有没有办法可以重命名在Android Studio或Gradle中用于所有其他模块脚本的顶级构建脚本?

Vig*_*dar 20

我的多模块项目遇到了同样的问题,这个解决方案对我有用.

  1. 关闭所有开放项目.
  2. 从"欢迎使用Android Studio"窗口中的最近项目中删除了项目.
  3. 现在点击"打开现有的android工作室项目"并浏览到项目仓库并选择顶级build.gradle.


Ser*_*kov 0

您只需添加包含文件build.gradle的根文件夹gradle.propertiessettings.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
Run Code Online (Sandbox Code Playgroud)