androidkotlinandroid-edittextandroid-chipsxml-layout

How to add chip to edit text in Android Studio


I found a dependency that I thought might help me, and it looked promising. But when I try to implement it I get a "Failed to resolve: com.hootsuite.android:nachos:1.1.1" :

https://i.sstatic.net/qgbEx.png

And the thing I'm trying to accomplish is this:

https://i.sstatic.net/d2JaU.png

as seen in this video : https://www.youtube.com/watch?v=UCZeHeDDBMw&list=PLi_3BTX1-5i4ieQOm-W-i3rkOU3qOA06o&index=3&t=401s&ab_channel=AndroidRion


Solution

  • Gradle's failing to resolve that dependency for some reason. First thing you should check is if there's a site for that library, or an entry in the repositories you're using, to check if that's a valid version or if there's anything else you need to know.

    Turns out it has a project repository on Github, so there's a readme telling you how to install it:

    Add this line to your project level build.gradle:

    buildscript {
     repositories {
       jcenter()
     }
    

    Add this line to your module level build.gradle:

    dependencies {
       implementation "com.hootsuite.android:nachos:1.1.1"
    }
    

    But in this case that won't help - JCenter shut down last year. The last update to this project was 4 years ago - but they have a JitPack link at the top of the readme. JitPack is basically a way to add dependencies from Github repositories, when they're not in a central repository like the Google one, or Maven Central. So try adding the config stuff at that JitPack link if you want to use this library (you could also build it locally if you really wanted)


    That said, Chips are part of the Material Components library now, so you might want to just use that instead - it's basically part of a typical Android app at this point. Scroll down to the Standalone ChipDrawable section to see how you can add one to a TextView