Trying to import code from GitHub into Android Studio

Pratik Thaker picture Pratik Thaker · Aug 19, 2015 · Viewed 9.2k times · Source

I feel incredibly dumb asking this, but I've downloaded the sample code of the Android Mobile Vision API available here: https://github.com/googlesamples/android-vision.

I'm trying to import this code into Android Studio so that I am able to just run the sample apps, but no matter how I import (Import Existing Android Studio Project, Import Non-Android Studio Project, Open Project), I am not able to get it imported in a way where I can just compile and hit play to run the app.

Since this is an official sample code from Android, I am sure it shouldn't be this complicated. What am I missing?

Answer

pm0733464 picture pm0733464 · Aug 21, 2015

There is a "Getting Started" page, which talks about how to import the sample projects:

https://developers.google.com/vision/getting-started

To download and set up the sample application in Android Studio:

  1. Download the Vision samples from Github.

You can either use the "Download ZIP" button on the Github Page or clone on the command line:

git clone https://github.com/googlesamples/android-vision.git

  1. Import the photo-demo project in Android Studio:

Click File > New > Import Project.

In the "Select Eclipse or Gradle Project to Import" window, navigate to the directory where you downloaded the vision samples repository.

Select the "photo-demo" folder and click OK.

Android Studio may prompt you to install the latest version of various Android libraries, especially com.android.gms.play-services in this case. Click "Install Repository and sync project" and follow the instructions.

  1. Connect your device over USB. You should see a notification that says ‘USB Debugging Enabled’. If you don’t see this notification, follow Step 2 here to enable USB debugging on your device, then plug your device in again.

  2. Run the app either by clicking the green arrow in the bar, or go to Run > Run 'app'.