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.
Related
I've been working on an Android app project. I'm using quite a few libraries (because why redo work that someone else has done to make other people's life easier?).
My question is: what are the costs of importing libraries in a project? (I'm talking about the implementation XXX.YYY:v2.0.0 type of line added in the build.gradle dependencies list.)
Just as an example (though please provide a more encompassing answer): when compiling and publishing my application, does it take all of the libraries' classes and methods and put them in my application, thus making it much heavier than it would need to be?
Each library dependency requires an additional download while you compile your app. So these will increase the amount of time required to compile.
The code for each library is included in your final APK so they will increase the size.
For Every Library a download is necessary In order to built your app.
e.g If you want Libraries regarding to Firebase then You download the Library by adding the Firebase Project to your App. In build.gradle File you see the dependencies after you add them to Your Project App.
I don't have much experiences with Android development and I have a doubt about the dependencies using Gradle. For example:
If I construct an Android app using Gradle dependecies and the package provider (for example picasso) remove the package from the repository, what will happens with my project? Will I lose the components? Or It makes a local copy of the binaries and my project will kept working normally?
Thanks a lot for help me to understand better how does it works.
You should keep a backup copy of the library you are installing as a dependency, but you shouldn't really worry about it ahead of the time that much.
It is quite rare, but it could get removed due to many reasons. There have been such instances in other cases where someone responsible for managing some package has just decided to remove it or alter it.
This does not just apply to Gradle but to any such dependency your application depends on, from any hosted package management solution. This same advice therefore applies to systems like NPM as well.
What you should ask yourself at some point in the development would be "Can I build this in 5 years again to fix a bug on a fresh machine with all the data I have and probably still have access to in 5 years?", because your local dependency cache might be long gone at that point anyways and the downloads for the library might be gone from the internet as well. It is a good practice to tuck them away somewhere in the same repository as the rest of the code, just in case.
Gradle downloads and caches all the dependencies when you perform Sync, you can see it at the bottom of your Android Studio.
If in the new version of library was deleted some packages, we have two options:
You update library version in your project and this package was removed for your project too
You use the old version of library and package still accessible from your project.
First, you should read that :
What is dependency management ?
The dependency cache
Short answer to your question : your project will still build unless your cache is cleared or if the dependency's version changes
But a package usually does not disappear from a repository (edit : as lu.koerfer underlined it in a comment, packages are not deleted from repository). If so, there might be a replacement package with a different name/group and you should update your dependencies to make it build properly again instead of relying on the cache.
If you will remove the dependency that you using, your project will still be able to use the library you willing to use.
until other dependency with same name / group will override your older dependency
You can read more about how gradle works, and how gradle manage his cache dependencies
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 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!
I'm studying the Busy Coder's Guide to Android Development and I'm running the projects from his GitHub repository. The thing is: there's like 100 projects at a minimum and every single one of them I have to add manually the ActionBar Sherlock and Google Play Services because the projects usually come with a broken reference to them. Is there a way that I can list all of my projects and just add the libraries to them all at once. This is such a pain and so unproductive.
As noted on the cw-omnibus repository home page:
These projects can be imported using the normal Eclipse import process. That being said, importing all the projects is probably a really bad idea, simply because there are so many of them. Import select projects, if and when you need them.
Beyond that, you are welcome to write yourself a script that fixes up the project.properties files to point to your locations of these library projects, for those project.properties files that refer to other locations.
You should switch to Android Studio; it's the future. With Android Studio, you can set up libraries as project libraries in Module Settings. Then, every module you add to that project can use those libraries.