How To Import External Library In Android Studio?
Solution 1:
I also use the PagerSlidingTabStrip
Project in my app and everything works fine.
I'm not sure if it's already possible to add a library project via the IDE (-> without any problems).
Please try to add the library project by editing the gradle files like this:
- first delete your module
PagerSlidingTabStrip
- then create a folder in your root project directory (->
NewOne
) named 'libs' - copy the complete folder 'library' of the
PagerSlidingTabStrip
project on git into 'libs' - rename the folder 'library' that you just copied to e.g. "PagerSlidingTabStripLibrary" (just to avoid confusion) -> after the renaming you should have the path: "NewOne/libs/PagerSlidingTabStripLibrary"
now add this library in your
settings.gradle
with the following command:include':libs:PagerSlidingTabStripLibrary'
go to your
build.gradle
file of your AppProjectaps
and add the following line to your 'dependencies':compile project(':libs:PagerSlidingTabStripLibrary')
at least you have to sync your gradle files: Tools -> Android -> Sync Project with Gradle Files
Please try this. If you get errors please post the log file.
Solution 2:
For update up to Android Studio 1.2.1.1
There are basically three types of dependencies which we have to add in project of android Studio
Add Normal Dependencies like Support files
- Right click on project->open module settings
- Select dependencies->Now press right "+" icon button ->Select library Dependencies
- Enter Name and Search
- Select file and press ok button.
Add Git Hub Dependencies
Find the dependencies of git repository for example compile 'com.jakewharton:butterknife:6.1.0' from https://github.com/JakeWharton/butterknife
A. open build.gradle(module:app) file
B. Add lines compile 'com.jakewharton:butterknife:6.1.0'
OR
Follow as describe above in Normal Dependencies Step by just enter dependencies in search bar
Add Jar files Dependencies
- Right click on project->open module settings
- press left "+" icon (insert new Module) button -> Select import Jar or .AAR package->browse Jar file and finish
- Now select dependencies-> press right "+" icon button ->Select module Dependencies->select jar files->press ok button.
Solution 3:
For what it's worth I had this problem and eventually solved it by consistently using the same sdk version & build tools across projects.
Post a Comment for "How To Import External Library In Android Studio?"