6

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?

pm0733464
  • 2,862
  • 14
  • 16
Pratik Thaker
  • 637
  • 2
  • 10
  • 18
  • "I am not able to get it imported in a way where I can just compile and hit play to run the app" -- which app? There are three independent projects here (in the `face/` directory), each of which would need to imported independently. – CommonsWare Aug 19 '15 at 21:17
  • Right, I see that, but I can't seem to get any of them imported into Android Studio in a workable condition. I see there already are gradle.build files in them - do I import them as an Android Project or Non-Android Project? In either case I am not getting the proper structure (there is nothing listed int he dropdown next to the play button). I'm fairly new at Android Studio and Gradle so that might be contributing to my confusion – Pratik Thaker Aug 19 '15 at 21:24
  • "do I import them as an Android Project or Non-Android Project?" -- I would use non-Android Studio project. "In either case I am not getting the proper structure (there is nothing listed int he dropdown next to the play button)" -- at least `FaceTracker` looks fairly conventional (I haven't examined the other two more closely). What version of Android Studio are you using? – CommonsWare Aug 19 '15 at 21:26
  • I'm using 1.0.2. Time to update? – Pratik Thaker Aug 19 '15 at 21:27
  • I would recommend moving up to a newer version. The current one is 1.3.0. – CommonsWare Aug 19 '15 at 21:27
  • OK, just updated. Trying this out. Will get back to you with my results – Pratik Thaker Aug 19 '15 at 21:42
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/87424/discussion-between-pratik-thaker-and-commonsware). – Pratik Thaker Aug 19 '15 at 21:43

2 Answers2

5

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'.

pm0733464
  • 2,862
  • 14
  • 16
0

From what I've read, it would be great if you updated to the latest version of Android Studio first, remember that these examples are very recent and thus, the version of the IDE they were developed on.

Also, note that there are three projects inside the repository. Their locations are the following:

  • [root-folder]/face/FaceTracker
  • [root-folder]/face/multi-tracker
  • [root-folder]/face/photo-demo

From there, you can just import each one as an Existing Project.

Jhoon
  • 59
  • 6