1

What is the best way to use an external library but with custom changes? For example, I am using an emoji library but I would like to change some of the emoji loading code to load 8 emojis per row instead of 10. This change would only affect 1 file and minimal code. I have tried submitting a pull request with a builder method that would set the number of emojis per row but it was rejected. I can compile the library as a aar with my custom changes and import it to my project but the original library changes quite quickly. How can I persist my custom changes AND keep up with the source repository easily?

My current process is: Rebase changes>Compile AAR>Import AAR>Discover errors>Reset custom branch to Master>Recreate the changes>Compile AAR>Works correctly!

More often than not, when the Master changes, I have to reset my branch to master and recreate the changes which is a bit time consuming.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Ray Li
  • 7,601
  • 6
  • 25
  • 41

1 Answers1

1

I would suggest that you maintain a fork of the library (I assume it's on Github - forks are easy to keep up to date with upstream) and then use Jitpack.

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Then, import a tag (or commit hash):

dependencies {
    compile 'com.github.User:Repo:Tag'
}
Adam S
  • 16,144
  • 6
  • 54
  • 81
  • This is an improvement over the current method I am using. It would cut out the Compile and Import AAR steps which is great! Do you have any suggestions for keeping my forks up to date with the master? I can watch a repo for changes but on popular repositories, there are A LOT of changes! – Ray Li Jul 11 '17 at 02:28
  • 1
    Unfortunately nothing beyond "put it on the calendar". I'm sure you could automate something, but updating dependencies is something you should probably still do (and test) by hand. Github makes it easy at least - one of my forks right now says I'm 412 commits behind `pinterest:master` and has a Pull Request button so I can easily get up to date. – Adam S Jul 11 '17 at 12:11
  • 1
    Thanks for the suggestions! I have a project with 20 or so dependencies. What process should I use to make sure they are all up to date? Is there a button that checks for you automatically in Android Studio because I am checking manually right now. – Ray Li Jul 11 '17 at 12:40
  • 1
    I actually have [another answer that covers exactly that](https://stackoverflow.com/a/35371234/1217087) :) – Adam S Jul 11 '17 at 14:23
  • 1
    ^This works! Another solution I discovered is creating a Library.io badge and including it in the ReadMe for an always available indicator of up-to-datedness. Just using Library.io works too :) – Ray Li Jul 12 '17 at 19:52