Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing top-level build.gradle in multi-module project

Tags:

I'm missing the "Top-Level" project build.gradle script from my project:

enter image description here

I imported it into Android Studio from a very complex Maven/Eclipse project, and it basically made a module ("android") in the top level of the directory, and added all the submodules ("tappurwear", "shared", etc) into that original module's directory.

I know this is a kind of messed up structure, but there's a lot of other build scripts so I can't really just move all the files into a proper separate module.

So now I'm wondering, how do I add a top-level build.gradle script, for the entire project? The usual Android Studio projects I've seen just have one, but it's treating my top-level build script as the "android" module's build script. Can I create a new build.script to be the top-level project script that shares settings with the other modules? Is there a way I can rename the top-level build script that gets used in all other module scripts, in Android Studio or Gradle?

like image 258
phreakhead Avatar asked Jul 19 '15 19:07

phreakhead


People also ask

What is multi-project build in gradle?

A multi-project build in Gradle consists of one root project, and one or more subprojects. A basic multi-project build contains a root project and a single subproject. This is a structure of a multi-project build that contains a single subproject called app : Example 1. Basic multi-project build.

Can we have multiple build gradle?

gradle for one project? Yes. You can have multiple build files in one project.

Where is module level build gradle?

The module-level build.gradle file, located in each project / module / directory, allows you to configure build settings for the specific module it is located in.


2 Answers

I had the same issue on my multi-module project, this solution worked for me.

  1. Closed all the open projects.
  2. Removed project from recent projects in "Welcome to Android Studio" window.
  3. Now click "Open existing android studio project" & browse to the project repo & select top level build.gradle.
like image 186
Vignesh Sundaramoorthy Avatar answered Sep 20 '22 17:09

Vignesh Sundaramoorthy


  1. close your project
  2. rename the project directory (in the workspace)
  3. open the project with the new name
  4. wait for gradle sync, build.gradle (project) should be added to the Gradle scripts
  5. close the project
  6. rename the project directory with the original name
  7. reopen the project with its good name
  8. wait gradle sync, the build.gradle should be here again...
like image 37
Christian Avatar answered Sep 22 '22 17:09

Christian