简体   繁体   English

尝试将代码从GitHub导入Android Studio

[英]Trying to import code from GitHub into Android Studio

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 . 我对此感到非常愚蠢,但我已经下载了Android Mobile Vision API的示例代码: 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. 我正在尝试将此代码导入Android Studio,以便我能够运行示例应用程序,但无论我如何导入(导入现有Android Studio项目,导入非Android Studio项目,打开项目),我不是能够以我可以编译和点击播放来运行应用程序的方式导入它。

Since this is an official sample code from Android, I am sure it shouldn't be this complicated. 由于这是Android的官方示例代码,我相信它不应该是这么复杂。 What am I missing? 我错过了什么?

There is a "Getting Started" page, which talks about how to import the sample projects: 有一个“入门”页面,其中讨论了如何导入示例项目:

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

To download and set up the sample application in Android Studio: 要在Android Studio中下载和设置示例应用程序:

  1. Download the Vision samples from Github. 从Github下载Vision样本。

You can either use the "Download ZIP" button on the Github Page or clone on the command line: 您可以使用Github页面上的“下载ZIP”按钮或在命令行上克隆:

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

  1. Import the photo-demo project in Android Studio: 在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. 在“选择要导入的Eclipse或Gradle项目”窗口中,导航到下载视觉示例存储库的目录。

Select the "photo-demo" folder and click OK. 选择“photo-demo”文件夹,然后单击“确定”。

Android Studio may prompt you to install the latest version of various Android libraries, especially com.android.gms.play-services in this case. Android Studio可能会提示您安装各种Android库的最新版本,尤其是com.android.gms.play-services。 Click "Install Repository and sync project" and follow the instructions. 单击“安装存储库并同步项目”并按照说明进行操作。

  1. Connect your device over USB. 通过USB连接您的设备。 You should see a notification that says 'USB Debugging Enabled'. 您应该会看到“启用USB调试”的通知。 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在您的设备上启用USB调试,然后再次插入您的设备。

  2. Run the app either by clicking the green arrow in the bar, or go to Run > Run 'app'. 通过单击栏中的绿色箭头运行应用程序,或转到运行>运行'app'。

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. 从我读过的内容来看,如果您首先更新到最新版本的Android Studio会很棒,请记住这些示例是最近的,因此,它们是在开发的IDE版本。

Also, note that there are three projects inside the repository. 另请注意,存储库中有三个项目。 Their locations are the following: 他们的位置如下:

  • [root-folder]/face/FaceTracker [根文件夹] /脸/ FaceTracker
  • [root-folder]/face/multi-tracker [根文件夹] /脸/多跟踪器
  • [root-folder]/face/photo-demo [根文件夹] /脸/光演示

From there, you can just import each one as an Existing Project. 从那里,您可以将每个导入为现有项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM