clue11
clue11

Reputation: 147

How to use github library in android studio

I am trying to use this ExtendedCalendarView from github: https://github.com/tyczj/ExtendedCalendarView but I am not clear on how to add this to my android studio project. I tried to create a libs folder in my project folder and then pulled to the libs folder. Then I tried to sync the project but it did not work.

Upvotes: 1

Views: 1305

Answers (2)

victorleduc
victorleduc

Reputation: 232

As they not offer gradle support, you need to download their library, and import it in Android Studio.

Do to this :

  • Go to File -> Project Structure
  • Then click the green + icon on the upper-left of the new window that just popped.
  • Choose Phone and Tablet application, and "Import existing Eclipse ADT or Gradle project as a module".
  • Select the library folder (the ExtendedCalendarView folder containing the AndroidManifest.xml folder), click Ok Next and Finish.
  • Wait for gradle project to sync
  • Then click on your main project module (often called "app"), and click on the upper-RIGHT green + icon, choose module dependency and select the extendedCalendarView module we just created. Then click Ok.
  • Wait for gradle project to sync

And you're good to go, your library is imported.

But, the library does not compile, you will see this error :

 Error:(11, 9) Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@icon value=(@mipmap/ic_launcher) from AndroidManifest.xml:11:9
    is also present at XXXXXXXXXXXXXX:extendedCalendarView:unspecified:13:9 value=(@drawable/ic_launcher)
    Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:8:5 to override

To fix it :

  • Add xmlns:tools="http://schemas.android.com/tools" to your AndroidManifest file, in the manifest element, next to your existing xmlns:android="http://schemas.android.com/apk/res/android"
  • Then add tools:replace="android:icon,android:theme" to your < application > element as the error message suggest.

Now the project compiles correctly !

Please ask me if you need any explanation or help.

Upvotes: 1

Nick H
Nick H

Reputation: 8992

Try cloning the library onto your computer then adding it as a module in Android Studio. Once you have completed that go to project settings and add the module as a dependency.

Upvotes: 1

Related Questions