Anthony
Anthony

Reputation: 35928

How can I import a library in gradle project Android Studio

I'm trying to import this library: https://github.com/vinc3m1/RoundedImageView

As mentioned on the README I added following in my build.gradle

 compile 'com.makeramen:roundedimageview:1.3.0'

and added the following in my xml

<com.makeramen.RoundedImageView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/imageView1"
        android:src="@drawable/photo1"
        android:scaleType="centerCrop"
        app:corner_radius="30dip"
        app:border_width="2dip"
        app:border_color="#333333"
        app:round_background="true"
        app:is_oval="true" />

After this if I Rebuild Project I keep getting an error

No resource identifier found for attribute 'round_background' in package 'com.myapp'

Should I be doing something else to import a library in my gradle project?

Upvotes: 0

Views: 604

Answers (2)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363429

Check the attrs on library:

https://github.com/vinc3m1/RoundedImageView/blob/master/roundedimageview/src/main/res/values/attrs.xml

The round_background attribute doesn't exist. If you check the history, this attribute has been changed in mutate_background

https://github.com/vinc3m1/RoundedImageView/commit/6d734ca0b99b7541039a03da615e7420b7b8238d

Change your xml:

<com.makeramen.RoundedImageView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/imageView1"
        android:src="@drawable/photo1"
        android:scaleType="centerCrop"
        app:corner_radius="30dip"
        app:border_width="2dip"
        app:border_color="#333333"
        app:mutate_background="true"
        app:is_oval="true" />

Upvotes: 0

Jitender Chaudhary
Jitender Chaudhary

Reputation: 701

You must have forgot to sync your project with gradle file.

  • Go to: Tools -> Android -> Sync Project with Gradle files
  • Or write this in your build.gradle

Code:

repositories {
    mavenCentral()
}

Upvotes: 1

Related Questions