How to use a library project in android studio
I'm not sure if it's already possible to add a library project via the IDE (-> without any problems).I do this by configuring the gradle files of my project like this:
- create a folder in your root project directory named
libs
- copy the folder
datetimepicker-library
tolibs
add this library in your
settings.gradle
with the following command:include ':libs:datetimepicker-library'
go to your
build.gradle
file of yourAppProject
and add the following line to yourdependencies
:implementation project(':libs:datetimepicker-library')
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.
I did it this way ,
- go to
project Structure
fromFile
menu - Select
modules
from the left pane - press on `+'
- complete the new module wizard steps
Make sure to make the module package name same as the module you want to add
- again open
Project structure
as in step 1 - select your project from the module list and on the right select dependencies
- Click on the
+
icon from right - select module dependency and then select the newly added module.
- copy files of the library project to the new directory created as module
- Done
Step 1:
Step 2:
!
Step 3:
Step 4:
....
Step 6 & 7:
Step 8:
The other answers make it seem more difficult than it usually is. Just add a single compile
line to your dependencies section of the app's build.gradle file.
In this case it is
dependencies { // ... compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'}
Gradle prompted me to sync and after I did so the library was automatically downloaded into my project.