I have been developing an application and I have came across to add the following dependency in the gradle.
dependencies {
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
}
I wonder how should I trust the github source code owner? What if source code owner deletes the source code?
Will my project fail if it could not able to find the github path?
Since the library is using jitpack and jitpack uses a mechanism of cache if the user removes the project the aar or jar will be reachable until the jitpack cache is valid. And at your local gradle also saves a copy of the library.
But your question is more that that, and yes, you should trust in the open source community. If you dont want to trust in Phil Jay work.. you can allways fork the project and use the code from your fork or just download the aar and import it directly from your project.
If you want to save a copy of the library you can download it directly from here: https://jitpack.io/com/github/PhilJay/MPAndroidChart/v2.1.6/MPAndroidChart-v2.1.6.aar
No when you first build the grandle, Android Studio look for it in the web, download and compile to use it. If you get it while it's active, you will have it in local drive, and can use it no matter if the source is erased.
Related
I have created a new module in Android Studio, and wrote my code in it. Now i want to upload it on github and get a gradle dependency which others can include in their project and use my library. How can i get it?
PS. I know how to use git, i just don't know how to upload just the library module and get the gradle dependency.
The esiest way is to create a git repository in Github and upload it there.
After that, you can use jitpack.io to use it with gradle.
The long old way, it is to create a Bintray project, and deploy it at MavenCentral and/or JCentre.
What do you need to do is upload your project to Bintray or sonatype
See here a good tutorial:
how-to-upload-library-to-jcenter-maven-central-as-dependency
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 would like to open source a library project that I am working on in android studio (hosted on GitHub) and allow others to include the project as a dependency.
Example:
dependencies {
compile 'com.test:myproject:1.0'
}
I've done some research, and have only discovered how to create a module and import it locally within my project. Does anyone know the necessary steps to take to achieve what I want?
Basicly you can publish your app on a public repository like maven or jCenter. The easiest way is to published on bintray, it's free for open source public library. You can use the following library to help you
Also, look into jitpack.io. It is easily the quickest way for getting a JVM projects up and ready especially if you're already using Github. Here's the extra docs for it as well.
I know that people use GitHub to deploy Maven artifacts (in a new branch) but since we are using Gradle I would like to know if there is a simple way of handling those dependecies as well?
We have different little projects that are independent but used by our main project and we want to manage those dependencies without including them locally.
Thank you.
There is an unofficial gradle plugin called Gradle Git Repo plugin that claims to do what you're looking for. Note however, that I did not play with it myself to verify that it works.
You could use JitPack to include your GitHub projects as dependencies. The idea is that JitPack provides a Maven repository where each package comes from a GitHub project.
It doesn't require that you upload files so it's quite easy to use. Instead when you request a file it builds it from source code.
There are two requirements to start using:
1. You need to have a build file in your project (Gradle or Maven)
2. You shoud create a GitHub release so that your project gets a version
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.