Android Studio add kt for import

I know this is a Kotlin forum only.
But maybe someone of you works with android studio an knows how to add kt files for import,

Background is this:
I published this to the forum “Animation for yall”. And of course i want to use it if needed. But i don’t want to do it by add a new kt file and copy the source in it.

Is there a way to include it by import?
So that im able to change it wheneever needed. Where should i save it and how should i do my import call and what else needed?

1 Like
A bit unrelated (click on the arrow to expand the text)

A bit unrelated, but btw there’s a categorization feature whenever you make a post, which helps people to figure out at a glance what topic you are asking about. It’s available right underneath the post title whenever you are making a post. For example, this post is related to the #Android category, and so it should be marked as such. I did it for you this time, but just for future reference it can really help you in getting an answer much more quickly because it catches the attention of the people who know how to answer your question, and like overall it just helps in keeping the forum organized.

Now back to the actual question at hand, your best bet is to create an Android Library and publish it. I’d suggest that you follow this tutorial and use this page from the Android documentation for reference.

1 Like

Thank you. But i prefer to wait until there’s a android studio update that can do that. I don’t know nothing about raywenderlich and don’t want to download from unknow source. Thanks

Did you click the link? Raywenderlich is a tutorial site with learning material.

As the raywenderlich (and the other link) suggest, one of your options for publishing your library is JitPack. IMO it’s the simplest option.

If you only want to reuse your code as a file, you could create a jar and pass that around directly instead of publishing it. Gradle also allows you to depend on Git repos (called Gradle source dependencies), which is another option for publishing–source dependencies may be just as easy as JitPack


Thank you

1 Like

raywenderlich is just a tutorial site that I found while searching lol. The download link is just of the materials that are already on the site, and so you don’t even have to use it. I linked it because it is very comprehensive and thorough and includes all the steps from A-Z, but yeah I can see where the confusion happened. The tutorial starts at this step btw.