Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Library Source into Android Studio

I am sorry for asking this newbie question.

I am trying to use this library in my project: https://github.com/gfranks/GFMinimalNotifications

I would like to import the source codes and not the binary.

The github page says Simply copy the source/resource files from the library folder into your project.

So I tried to drag and drop these two files directly to my libs folder in Android Studio.

And I went back to my Activity and try to use it in my code. But the autocomplete does not seem to recognize the library.

Any help, please? After I copied into my libs folder.

Importing the whole module seems to be wasteful considering the project has many assets that are irrelevant to the library itself.

Found the solution

I copied it to the app/libs folder, and then in build.gradle I add

sourceSets {
    main.java.srcDirs += 'libs/GFMinimalNotifications/src/main/java'
}
like image 929
JayVDiyk Avatar asked Dec 20 '15 11:12

JayVDiyk


People also ask

How do I import library to Android?

To use your Android library's code in another app module, proceed as follows: Navigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Library Dependency in the dropdown. In the Add Library Dependency dialog, use the search box to find the library to add.

Where will you add the library in Android Studio project?

Go to Android Studio and navigate to File -> New -> Import Module -> Select the library path -> Finish.

Can we import module from source in Android Studio?

Import a module To import an existing module into your project, proceed as follows: Click 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.

Where is the libs folder in Android Studio?

How to find the libs folder in Android Studio? If you are unable to find the libs folder in Android studio then open your android project in “Project” mode If the project is already opened in the “Android” mode. Then go to Your Project Name > app > libs and right-click on it and paste the downloaded JAR files.


2 Answers

Steps to add modules in Android Studio download zip file & follow steps

Follow Step first

Step second Step third Step fourth

like image 154
Ajinkya Avatar answered Sep 28 '22 08:09

Ajinkya


copy in project full package library

in settings gradle add include ':library',':app'

in build.gradle

dependencies {
    ...
    compile project(':library')
}

enter image description here

like image 32
PeDuCKA Avatar answered Sep 28 '22 08:09

PeDuCKA