Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing multiple projects and single projects into Android Studio

I need to be able to import all of our projects in android studio and i need to be able to import just a single project, and its dependencies, into android studio.


Current project structure:

  • branch/
    • Apps/
      • Project1/
        • build.gradle
      • Project2/
        • build.gradle
      • Project3/
        • build.gradle
      • build.gradle
      • settings.gradle
      • gradlew
      • gradlew.bat
      • gradle/
    • OtherStuff/

I can import the branch/Apps/build.gradle fine and it imports all the projects under Apps and compiles all the projects in settings.gradle and works fine. However, i also need to be able to import just one project, and its dependencies, into android studio and it work fine.

Right now when i try to import the branch/Apps/Project1/build.gradle Android studio gives the following error:

You are using an old, unsupported version of Gradle. Please use version 1.8 or greater.
Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)

How can i import a single project and have it use the gradle wrapper that the MASS import of all the projects is using? Or is there a better way to handle this situation? Maybe i am just doing it completely wrong.

This effects Android Studio Version is 0.3.7 and 0.4.0.

Thanks

like image 264
prolink007 Avatar asked Dec 18 '13 16:12

prolink007


1 Answers

Android Studio expects to see a settings.gradle file at the root directory of its project, and likes to have the Gradle wrapper files at the root as well. If you're trying to open, say, Project1 as an independent project, that's the problem you're running into -- neither of those things is in Project1's directory. If Project1 is just a module in the larger Apps project, those things aren't necessary.

What are you trying to do? Maybe there's a better approach rather than opening a subproject independently.

EDIT:

It works for me if I copy the Gradle wrapper files (gradlew, gradlew.bat, and the gradle directory) into the subproject's directory, and also add a settings.gradle file that looks like this:

include ':'

Here's a screenshot of my project's layout, where I've edited LibA to be able to be opened independently:

Screenshot of Project view showing files in app and LibA directories

Note that if your subprojects have dependencies on each other (e.g. Project1 depends on Project2), then this scheme isn't going to work. Right now Android Studio would only understand that in the context of a larger project with a root directory that can encompass all dependencies.

like image 88
Scott Barta Avatar answered Oct 24 '22 19:10

Scott Barta