How to create a custom Android view library in Android Studio?

I created a custom view that extends the RelativeLayout for the project I'm working on. I think this may be useful to others, so I tried to set it up as a library so that others could find and use it.

I could not find a clear answer on how to do this in Android Studio.

To be clear - I already created the view, and it works fine, I just want to pack it as a library.

Create a new project and just post your code there, or do I need to create a new module? As soon as I do one of these actions, what parts of the manifest and gradle files do I need to change?

Finally, do I need to somehow get the AAR from the files, or is it best to upload it to GitHub and let others clone it?

+5
source share
1 answer

In Android Studio (v 1.0.2):

File → New Module ... → Android Library

In this new module, place all the code you want to split. Android Studio should update Gradle settings accordingly.

You can publish your library as source code and / or artifacts in some Maven / Gradle repository. Public source code allows others to contribute to your work, fix bugs, or extend functionality. However, if you just do this, it will not be very convenient to reuse it for other developers, because working with the source requires verification and assembly. If you also publish artifacts (in some Maven / Gradle repositories) created from this code, you will simplify the life of people using your code :)

+1
source

Source: https://habr.com/ru/post/1204353/


All Articles