Getting a Sampler Project

Relevant portions of the Sampler projects are shown directly in this book, including links to the GitLab Web site where you can view the full source files. So, if all you want to do is to read the code, you do not need anything more than this book and a Web browser.

If, on the other hand, you want to run the sample code, or perhaps modify it as part of your own experiments, you will need to get one or both of the Sampler projects onto your development machine and into Android Studio. You can do that completely from inside Android Studio if you wish, or you can get the source code separately and then import it into Android Studio.

Direct From Android Studio

Android Studio has built-in support for Git. You can download and import a Git project into Android Studio via File > New > Project from Version Control from an existing Android Studio window.

If you are at the Android Studio “welcome” dialog, click “Check out project from Version Control” and choose Git from the menu. If you already have a project open in Android Studio, choose File > New > Project from Version Control from the main menu.

This will bring up a “Get from Version Control” dialog box:

Android Studio Get from Version Control Dialog
Android Studio “Get from Version Control” Dialog

Choose “Git” in the “Version control” drop-down. Then, in the “URL” field, fill in the Git URL for the project that you want to clone:

In the “Directory” field, you can provide the path to the directory on your development machine where you want to put the source code. This needs to be a new empty directory, but otherwise it can be wherever you want. The folder icon next to that field will bring up a directory chooser window to help you pick or create the directory that you want to use.

Then, click the “Clone” button to download the code and begin importing it into Android Studio. After a short while, your project will then be opened into an Android Studio window and be ready for use.

Manually

If you prefer to use other tools to work with Git repositories, you are welcome to do that too.

Clone or Download

Using your favorite Git client, clone the repository from its associated URL:

Import

Then, in an existing Android Studio window, you can choose File > New > Import Project to bring up a file/directory chooser. Alternatively, if you are at the welcome dialog, choose “Import an existing project” to bring up that same chooser.

Select the directory into which you cloned or unZIPped the Git repo, then click OK. It should open up right into an Android Studio window.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.