How to Upload Code From Android Studio Into Github

Android Studio makes it easy to button changes to your favorite Open up Source, professional, or personal projects on GitHub. In this tutorial, nosotros'll learn how to use GitHub with Android Studio. We'll utilize an Open up Source contribution for context.

Android developers use Open up Source projects to speed up development or enable functionality that is otherwise impractical to build. Therefore it's essential to understand how to give dorsum and improve the Open Source projects that we use.

Requirements

  • A GitHub account
  • Android Studio installed

Selecting project

First of all, to which Open Source project should y'all contribute? You can contribute to any project, but, ideally, information technology'south i that you know and use.

In this tutorial, I'll use a contribution to Stream Chat's library for Android as an example. It'south a popular SDK to transport high-quality conversation experiences on Android.

Notice how easy information technology can be to build chat into your app with our Android In-App Messaging tutorial.

What to contribute

Sometimes, during the usage of an Open up Source library, we encounter bugs that nosotros wish were fixed and missing features that we want added. When that happens, information technology'due south tempting to request it to the maintainer(s) and hope for the best, or fifty-fifty search for another library. Withal, it's essential commencement to consider contributing with that bug prepare or feature we want. It's oft not as complicated as nosotros may think.

Alternatively, we may want to contribute to the project in general and select a request that's made past the customs. In this case, the all-time mode to find an idea is to look through the issues listing and select an issue that seems elementary plenty for a starting time contribution.

Image shows the Stream Chat Android library issues list

For this tutorial, I'll fix a problems that I encountered while testing the sample app. In this case, the sample app crashed when pressing an image inside the chat, instead of showing it in full screen.

Cloning the repository

With Android Studio, you don't need to apply the concluding to contribute to an Android project on GitHub. It has native integration with git and GitHub to let nearly actions via the Android Studio UI.

When you open up Android Studio, information technology offers the selection to open up a projection from version control. That's the option we'll use.

Image shows Android Studio welcome screen with an arrow to the Get from Version Control button

After selecting that option, yous can blazon the URL of the repository, press "Clone", and select a folder. Subsequently that, Android Studio will do all the piece of work and open up the project ready to go.

Image shows two Android Studio screens. One for typing the git repository URL and the other loading it as a project.

Making the change

Initially, the default branch volition be selected, but often projects take a development branch that receives the changes before merging them to master. Let's create a co-operative for our change based on that development branch. That is a better practice than using the development branch directly, to not risk polluting it.

Image shows Android Studio opened with an arrow pointing to the label where it says Git: default branch

To do that, click where it says "Git: [default branch]", select the development branch, click "New Branch from Selected", and choose a proper noun for your branch.

Image shows dropdowns with the branches and a dropdown from development branch with "New branch from selected" option selected and a dialog to name the new branch

Afterwards that, nosotros tin go along with making the modify we want. After debugging the project, I've identified that initializing Facebook's Fresco library in the MessageListView grade solves the event.

Image shows Android Studio with changes made to the MessageListView file to initialize the Fresco library

Now that we fixed the issue, we're ready to commit it and send a Pull Request to the master GitHub repository. The next step will prove how to fork the repository, in example you don't have permission to push a branch to the main repository, which is often the case if you're not a maintainer of that projection.

Forking the repository

If y'all're not a maintainer of that repository, you can't push your co-operative to it. You'll need to fork information technology outset and push the branch to your fork. To do this, go to the GitHub repository and press fork.

Image shows a GitHub repository page with an arrow to the Fork button

You'll need the URL of your repository in the next stride, as we'll push the branch to it.

Committing and pushing the change

Now, we can commit our change. To practise this, either printing CMD+K (or CTRL+M on Windows), or navigate to Commit via the carte du jour.

Image shows the menu dropdown with the commit button

Review your changes in the screen provided, write a descriptive commit message, press the arrow on the "Commit" button, and select "Commit and push". That will accept yous to the screen where yous'll cull which repository the co-operative will be uploaded. If you're a maintainer of the origin remote, you tin press "Push" and skip to "Creating the pull request".

Image shows the screen to choose which repository to push to

If you're not a maintainer, you should press the "origin" label, which will allow you to define a new remote repository. After that, yous however need to select the proper remote and press the "Push" button.

Image shows the remote being switched and an arrow to the push button

If you're not yet authenticated, Android Studio will inquire for your GitHub credentials.

Image shows dialogs to authenticate with GitHub

After you authenticate, Android Studio will send the changes to your remote repository.

Creating the pull asking

Now, get to your repository page on GitHub, and you'll see a prompt to open a Pull Request with your newly pushed branch.

Image shows GitHub repo page with a prompt to open a Pull Request with newly pushed branch

When you press that, it volition take you to a Pull Asking composer. By and large, it will already contain a template that you tin follow to draw your PR and some instructions that you lot need to follow. Also, don't forget to cheque out the contribution guidelines of the project if it has one.

Image shows Pull Request being composed and the base branch being switched to develop

Commonly, GitHub will pick the master branch as a base, then don't forget to switch it to the development branch, if information technology exists, every bit the image shows.

Wrapping up

Congratulations! You just learned how to contribute to an Open Source project using GitHub and Android Studio, without having to touch the control-line interface. Afterwards yous've sent your Pull Request, the project's maintainers volition review information technology and ask for changes if needed, in which case y'all can follow the "Committing and pushing the change" stride again.

At Stream, we have many Open up Source Android projects in Kotlin and Java, and we're happy to receive and aid you lot with your contributions.

taylorfortint.blogspot.com

Source: https://getstream.io/blog/use-github-android-studio/

0 Response to "How to Upload Code From Android Studio Into Github"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel