Reputation: 291
Good Day
I am relatively new to android development, so I am having a hard time adding a library to my project. This whole gradle thing is confusing me big time. I have this CircleImageView library i found from https://github.com/Pkmmte/CircularImageView and the readMe file says I must include the following line of code "compile 'de.hdodenhof:circleimageview:1.3.0'" in the dependencies block in the build.gradle file but Im pretty sure there other steps required because nothing is working, I get varying errors, one minute I get"Failed to resolve:circleimageview", next thing is "Could not find default name", I am at my wits ends right now, please assist and please be nice.
P.S. I am using Android Studio 1.1.0
Upvotes: 0
Views: 1954
Reputation: 15414
I understand that the gradle build system can be a pain for beginners but in fact its very simple. I'm going to show a step by step process to add the above CircularImageView library to your project.
First off, in your build.gradle
file add the following piece of code.
compile 'com.pkmmte.view:circularimageview:1.1'
You get the above code from the CircularImageView's README.md file.
Next thing is you make your project. (Cmd + F9 on Mac)
Thats about it. You have successfully added CircularImageView as a dependency in your project. Now to use the same in your code, you can do something like this
Note that the above code will give you an error at app because the namespace app
is not bound.
So you will have to modify your xml file to include the namespace as follows.
xmlns:app="http://schemas.android.com/apk/res-auto"
So your overall xml file will look as follows.
P.S. I'm sorry I couldn't add the code for the last step because of some weird formatting issues. Hence the screenshot. Hope that helps.
Upvotes: 1
Reputation: 889
To use the library you only have to add
dependencies {
compile 'com.pkmmte.view:circularimageview:1.1'
}
in the dependencies block in your gradle file, like you already said.
After you built your project you can use the CircularImageView of the library.
If you have further problems, you can have a look at the examples in github how to use the CircularImageView.
Upvotes: 1