I just installed the new Android Studio and I'm looking for a way to import the support library for Android.
Where is the option for that? In Eclipse that are just two clicks. I googled for it but found nothing. Surely it is too new.
I just installed the new Android Studio and I'm looking for a way to import the support library for Android.
Where is the option for that? In Eclipse that are just two clicks. I googled for it but found nothing. Surely it is too new.
I no longer work on Android project for a while. Although the below provides some clue to how an android studio project can be configured, but I can't guarantee it works flawlessly.
In principle, IntelliJ respects the build file and will try to use it to configure the IDE project. It's not true in the other way round, IDE changes normally will not affect the build file.
Since most Android projects are built by Gradle, it's always a good idea to understand this tool.
I'd suggest referring to @skyfishjy's answer, as it seems to be more updated than this one.
The below is not updated
Although android studio is based on IntelliJ IDEA, at the same time it relies on gradle to build your apk. As of 0.2.3, these two doesn't play nicely in term of configuring from GUI. As a result, in addition to use the GUI to setup dependencies, it will also require you to edit the build.gradle file manually.
Assuming you have a Test Project > Test structure. The build.gradle file you're looking for is located at TestProject/Test/build.gradle
Look for the dependencies section, and make sure you have
Below is an example.
You can also add 3rd party libraries from the maven repository
The above snippet will add gson 2.2.4 for you.
In my experiment, it seems that adding the gradle will also setup correct IntelliJ dependencies for you.
You can simply download the library which you want to include and copy it to libs folder of your project. Then select that file (in my case it was android-support-v4 library) right click on it and select "Add as Library"
=============UPDATE=============
Since Android Studio introduce a new build system: Gradle. Android developers can now use a simple, declarative DSL to have access to a single, authoritative build that powers both the Android Studio IDE and builds from the command-line.
Edit your
build.gradle
like this:NOTES: Use + in
compile 'com.android.support:support-v4:21.+'
so that gradle can always use the newest version.==========DEPRECATED==========
Because Android Studio is based on IntelliJ IDEA, so the procedure is just same like on IntelliJ IDEA 12 CE
1.Open Project Structure (Press F4 on PC and Command+; on MAC) on your project).
2.Select Modules on the left pane.
3.Choose your project and you will see Dependencies TAB above the third Column.
4.Click on the plus sign in the bottom. Then a tree-based directory chooser dialog will pop up, navigate to your folder containing android-support-v4.jar, press OK.
5.Press OK.
In Android Studio 1.0, this worked for me :-
Open the
build.gradle (Module : app)
file and paste this (at the end) :-Note that this
dependencies
is different from thedependencies
insidebuildscript
inbuild.gradle (Project)
When you edit the gradle file, a message shows that you must sync the file. Press "Sync now"
Source : https://developer.android.com/tools/support-library/setup.html#add-library
This is way more simpler with Maven dependency feature:
Hope this will help!
Android no longer downloading the libraries from the SDK manager, it has to be accessed through Google's Maven repository.
You will have to do something similar to this in your build.gradle file:
Find more details about the setting up process here and about the different support library revisions here.