Question

How can I add library project on my new project which is made by Android Studio ?

I want to test open source project(HoloGraphLibrary) so made new Project on Android Studio.

here is the project structure(Project name is Test44Project and Module name is Test44)

Test44Project
- .idea
- gradle
- Test44
- build.gradle
- Test44Project.iml
- else

download HoloGraphLibrary, copy and paste into Test44Project Folder.

finally i got project structure like this.

Test44Project
- .idea
- gradle
- HoloGraphLibrary
- Test44
- elses

and modified .iml, build.gradle and Etc. for build and run.(finally it can build and run on my device)

This is correct??

When I want to add library project to my project, always copy and paste library on my project folder?

I don't understand...

Can i get example project(using library project) which is following gradle project structure?

Was it helpful?

Solution

Ya you are correct( No need to update .iml files only build.gradle and settings.gradle) but this not only the way for adding dependencies in gradle. The method you are following should only be used, if the library you want to use don't have maven dependency.

For example actionbarsherlock library has its maven dependency, In such cases no need to download the whole library and add it as as module in your project, instead add the maven gradle dependency in your module's build.gradle file like

dependencies {
       compile 'com.actionbarsherlock:actionbarsherlock-i18n:4.4.0@aar'
}

That's it.

Gradle supports both Local and Maven repository, The above example is of maven repository. Where adding support libraries are the example of Local repository, In which you don't need to add Jars in your libs folder and add them in to Build Path instead you can use

 dependencies {
      compile 'com.android.support:appcompat-v7:+'
}

This is not in maven central repository. It is located in your sdk directory. You can find it in SDK/extras/android/m2repository or if you can download it from SDK Manager> Extras > Support Repository.

Here is a sample project you can have a look for the same. https://github.com/pyus-13/TesstApp

You can add maven dependency from File > Project Structure > Dependencies add green "+" button and choose Maven Dependency

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top