I'm getting really confused and frustrated because I just can't understand how to import my android library project as dependency for my application project.
I tried to find online and most of the answers suggested to go to project structure of my application and click on '+' and then click on 'import module'
But Android Studio 0.3.4 - 0.5.2 doesn't show any options and when I click on '+', it just shows the windows for a new module.
Am I doing something wrong or what ?
Help!!!
Import a moduleClick File > New > Import Module. In the Source directory box, type or select the directory of the module(s) that you want to import: If you are importing one module, indicate its root directory.
In Android Studio, Right-clicking on the folder to add as library. Editing the dependencies in the build. gradle file, adding: compile fileTree(dir: 'libs', include: '*. jar')}
Select the source directory of the Module you want to import and click Finish. Open Project Structure Dialog (You can open the PSD by selecting File > Project Structure) and from the left panel click on Dependencies. Select the module from the Module(Middle) section In which you want to add module dependency.
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:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With