I am using an open source library project from GitHub in my Android Application. I've modified that library to work with my specific needs. Now that library has been updated with more cool features.
If I want to use the updated library, I've to download it and again I've to put my older modifications manually. Instead of that is there any process, so that I can use latest libraries from GitHub still with my modifications.
Your help is appreciated.
You want to fork that repository on Github, add your changes onto that, then merge the upstream changes once they come out. You could even add your fork of this library as a submodule in your main project.
Hope that helps. Good luck!
Related
I have an Android project in which I have added Android library as a module and use it within the project. Android library module is part of the project.
what I want to do is, remove the Android library from the project and host it in Github and use the Android library as a dependency in Android project.
Is that possible, if so how can I achieve that please.
If you think I should not be creating a Android library within the Android project I want to use it in, and create Android library as a separate project do let me know as well. (But this was it is a bit hard to debug I think)
Your suggestion and advice will be very helpful
Thanks
R
You need to publish your Library to Github Packages in order to use it as a dependency.
Follow this tutorial to do it.
Update 1
Another way to do that is by using JitPack. You just need to publish your library into Github repository and then you create a dependency using JitPack from that repo.
I have one doubt regarding using library from GitHub to Android Studio if anyone help me to solve my doubt, I would be thankful.
My question is
if we want to use library from GitHub , we have two option
either we can use dependencies to import library in project
or we can download the library from GitHub and use it as a module in our project
from above option which one would be good way to use library? (from all perspective)
Dependency
Because whenever a new version of a library arrives you don't have
to continuously check and look for it, let your build tool take care
of that. It can be cumbersome to regularly download and manage
different versions of libraries. That's where build tools like
Gradle comes in and informs you about an update and download it for
you.
You should always use library from github via using dependencies. Why?
You probably won't have times to check and fix the bugs of the library in the future.
You need more time to learn about the library nuts and bolts to maintain and update the library in the future.
You probably don't have enough expertise about the domain of the library.
You need to catch and recreate the bugs you found in your system. So, you need to keep an exact version of each libraries in your project.
You can update and change your dependencies easily without afraid of introducing new bugs.
Make your project clean.
So I am starting to work on some open source libraries that is out there, mainly I have found bugs with the library using my specific project. As far as I know the Gradle library dependency is cached somewhere and not accessible.
What I would like to do is be able to create a branch for the fix and test in my project. Is there efficient way of doing this or do I need to comment out my gradle dependency and do a manual import of the library and do the fix?
I think that project is available on GitHub? You have 2 options then:
Open a issue at the project and describe your problems. Maybe the author will fix them himself
Fork the Project. You can work on your own on it then and make a Pull Request later if you want to.
You can of course download the source code and modify it yourself locally too, but that's not the purpose of Open Source Projects I think :)
I'm a beginner in Android programing, and I'm working with android studio...now i wander what is the best way for installing open sources libraries from gitHub.
my question is from organization principles point of view-
should i create a new package for every library and put all the library source code as is in that package? should the package be in the source.main.java folder?? (the one that the android studio creates automaticly).
sorry for the dumb question...it's just that im taking my first baby steps in a big scale program and i don't want to loose my head in the future because of bad organization practices.
There's no right answer to this question. A few wrong ways to do it, but common sense will guide you.
My advice:
Start by having the source of this open source code checked into your company's source control system somewhere and capable of being built or re-built as needed. Not necessarily in your project, but just getting the code checked in so it can't be lost or confused with the original author's ever evolving changes on GitHub.
As to how you consume it, you have several options.
Build the open source in it's own project (checked into source control, but separate from your main project). Then just take the drop of compiled files (.class, .jar, .lib, etc...) and check that into your main project. This is the most flexible option if you don't think you are ever going to need to change the open source code that often. Has the side benefit of being managed for several projects.
Drop the source code as-is directly into your project. This means you will always be rebuilding the code. This gives the most flexibility with evolving and changing the the code specific to your project needs.
There's probably hybrid solutions of these options as well.
The bottom line is that whatever you use needs to be copied and building in your own system. Because the code you pulled down from GitHub could go away or change significantly at any time.
A simple solution would be to use JitPack to import those GitHub projects into your gradle build.
First you need to add the repository:
repositories {
maven { url "https://jitpack.io" }
}
and then all the GitHub repositories as dependencies:
dependencies {
compile 'com.github.RepoOwner:Repo:Version'
// more dependencies...
}
Behind the scenes JitPack will check out the code and compile it.
I think you are looking for this. If you are using eclipse, you should check this
If you are looking for adding jar file to your lib, you can simply create a lib folder in your project and add jar file into the library and you must add the line compile files('jarfile.jar') in the build file(gradle build). If you are using eclipse you can follow this
By the way, creating a package for each library and putting all library source codes doesn't look sane to me. It is almost equivalent to recreating the project. I'm sure that it is not the proper approach.
If the third-party code is packaged as a .jar or a .aar and made available in public-facing maven repository (e.g. maven central), then you should add the library as a dependency in your build.gradle file.
If it is not available as a maven/gradle dependency, you could add the library's code to your project as suggested in other answers here. I have never liked that solution at all.
You could also build the .jar or .aar and add that to your project's lib directory, as also suggested by other answers here. For a small, simple project with few dependencies, that might make sense.
What I like to do for larger, longer-lived projects, is to set up my own Nexus server (a Maven repo server), and put the third-party dependencies there.
I was wondering what the easiest way is to display a simple graph of any sort based on values that I already have. I tried using a library but ended up with more errors than i can count. What is the trick to using libraries and can someone take a second and help walk me through the steps because online all i can find is tutorials that just go: Download this jar. put it in libs and tah dah. But I am not seeming to find such luck.
Is there a way to download it as if it was a compelete project and then just import it? Or do you have to go through and pick out each little thing?
Quoting the project documentation:
Recommended: If you use Gradle/Android Studio you can use the library from Maven Central.
Add that line to your build.grade file into the dependencies block:
compile 'com.jjoe64:graphview:3.1.3'
Download .jar file and copy it into the libs folder of your project.
GraphView-3.1.3.jar
Download or clone the git repository and link your project with the GraphView library project.
jjoe64/GraphView on GitHub
Since you have the question tagged with eclipse, option #2 would seem to be the most likely choice.
Note that the author also provides:
a series of demo projects
JavaDocs for the library
both of which may help you learn how to use it, as an adjunct to the rest of the documentation.