Can't find import module option in project structure (Android Studio 0.3.4 - 0.5.2)
You'll run into this when working with Gradle-based projects, as this one is; even in 0.3.2, this Import project command was doing the wrong thing; it would seem to work, and would make syntax coloring in the editor work properly, but it would fail when you would try to build and run your app, and your changes would be lost when you re-synced the project with the Gradle build files. This is why this has been removed until it can be properly reimplemented. The bug to track it is at https://code.google.com/p/android/issues/detail?id=62122
In the meantime, to add an existing library as a dependency, you'll need to do it by hand in your Gradle build files. To do so, move the library so its directory is under the project root (at the moment, including modules outside the project root isn't supported), write a build.gradle
build file that will build the module, and include the module in your settings.gradle
file.
You might find it easier if you go through the File > New Module... command to create a blank module, choosing either a plain Java module or an Android module as appropriate, and copying the library files into the module directory where they need to go. That will take care of the Gradle files for you and set up the skeleton directory structure.
For android studio 0.5.7, volley was successfully imported as a library project following these steps:
- Create a directory named "libraries"(whichever you want) under your project root
-
Clone volley using git under the directory created in step 1, command is "git clone https://android.googlesource.com/platform/frameworks/volley". Now the project structure looks like:
[Project root] |- [Your module] |- libraries |- volley
- Import volley through : Right click project root -> Open Module Settings -> Click "+"(New Module) in the up left corner -> Import existing project -> Select volley source directory -> Next After step 3, volley is imported, but dependency on library project volley is not setup yet.
- Setup module dependency : Right click project root -> Open Module Settings(Now volley should appear in the module list) -> Choose [Your module] -> Switch to tab "Dependencies" -> Click "+"(Add) in the left bottom corner -> Choose "Module dependency" -> Select ":volley" in the module list dialog
- Now everything works fine, you can use volley as you want
I had similar problem. I opened settings.gradle
file and add the library include ':Test', ':libraries:MyLibrary'
, then in build.gradle
add the line: compile project(':libraries:MyLibrary')
. If you do: Right Click at the project -> Open Module Settings -> your project -> Dependencies, you will see the same dependencies in build.gradle
. By the way, after this actions I restarted Android Studio, then IDE created *.iml file.