-1

I am very new at implementing custom libraries from github.com

Here is the link I tried to follow:

https://github.com/makovkastar/FloatingActionButton

It seems easy to implement this floating action button, but I need someone to teach me how to follow this instruction.

I get stuck here:

3) Attach the FAB to AbsListView, RecyclerView or ScrollView : ListView listView = (ListView) findViewById(android.R.id.list); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.attachToListView(listView); 

because I don't have FloatingActionButton.java in my project.

Do I have to download all these files :

https://github.com/makovkastar/FloatingActionButton/tree/master/library/src/main/java/com/melnykov/fab

and put all of them inside my package?

I just need some beginner-level guidelines..

3
  • 4
    do you have google in your country ? Commented May 5, 2015 at 9:52
  • Do you have this declared at the top of your main activity: import com.melnykov.fab.FloatingActionButton; ? Also, are you getting any errors? Commented May 5, 2015 at 9:56
  • Wow, how surprising, I found a duplicate question by typing "third party library android studio" in Google Search. /sarcasm Commented May 5, 2015 at 10:10

2 Answers 2

3

When you use Android Studio, you generally use gradle build system, and gradle dependencies.

In your project, you have you're root project build.gradle which is usualy tiny (~20 lines) and stay tiny. the second build.gradle is you're application gradle, the application you launch on you're device.

This is the hierarchy :

/ build.gradle (project gradle) app/ src/ build.gradle (app gradle) 

The build.gradle you have to update is normally the application gradle. You will see that it's already include some dependencies :

dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) ... } 

Most library on github use Maven/Jcenter to publish the library online. Gradle take part of this and allow you to add dependencies really simply. Gradle will also merge manifest and ressources from library when you build you're app.

For FAB, the developer write in README.md the integration tutorial which include

compile 'com.melnykov:floatingactionbutton:1.3.0' 

To add a library via gradle, follow this :

  1. Add gradle dependencies to you're dependencies part of you're app gradle.

    dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) ... compile 'com.melnykov:floatingactionbutton:1.3.0' } 
  2. Lastly, Android Studio will prompt you to "Sync NOW", click on the button, let android download and compile the library and you're good to go.

Sign up to request clarification or add additional context in comments.

1 Comment

I see. "Sync Project With Gradle Files" was what I was missing on. Thanks
0

Clone the project first and place it in same folder as your app, then follow these steps

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.