如何将现有项目从 GitHub 导入 Android Studio

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25348339/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:21:33  来源:igfitidea点击:

How to import an existing project from GitHub into Android Studio

androidgitandroid-studio

提问by Huy Duong Tu

I've just imported EdgeEffectOverride project from Github into Android Studio. This is the screen shot
enter image description here

我刚刚将 EdgeEffectOverride 项目从 Github 导入到 Android Studio。这是屏幕截图
在此处输入图片说明

When I run the project, I get the error: Error running build: Module 'EdgeEffectOverride-master' is not backed by gradle.

当我运行项目时,我收到错误:Error running build: Module 'EdgeEffectOverride-master' is not backed by gradle.

回答by Siva Prakash

You can directly import github projects into Android Studio. File -> New -> Project from Version Control -> GitHub.Then enter your github username and password.Select the repository and hit clone.

可以直接将github项目导入Android Studio。 文件 -> 新建 -> 来自版本控制的项目 -> GitHub。然后输入您的 github 用户名和密码。选择存储库并点击克隆。

The github repo will be created as a new project in android studio.

github repo 将在 android studio 中创建为一个新项目。

回答by Priyanshu Sekhar

Unzip the github project to a folder. Open Android Studio. Go to File -> New -> Import Project. Then choose the specific project you want to import and then click Next->Finish. It will build the Gradle automatically and'll be ready for you to use.

将 github 项目解压到一个文件夹。打开安卓工作室。转到文件 -> 新建 -> 导入项目。然后选择要导入的特定项目,然后单击 Next->Finish。它将自动构建 Gradle 并准备好供您使用。

P.S: In some versions of Android Studio a certain error occurs-
error:package android.support.v4.app does not exist.
To fix it go to Gradle Scripts->build.gradle(Module:app) and the add the dependecies:

PS:在某些版本的 Android Studio 中会出现某个错误-
错误:包 android.support.v4.app 不存在。
要修复它,请转到 Gradle Scripts->build.gradle(Module:app) 并添加依赖项:

dependencies {      
    compile fileTree(dir: 'libs', include: ['*.jar'])  
    compile 'com.android.support:appcompat-v7:21.0.3'  
}

Enjoy working in Android Studio

享受在 Android Studio 中工作的乐趣

回答by Bob Ingram

In Github click the "Clone or download" button of the project you want to import --> download the ZIP file and unzip it. In Android Studio Go to File -> New Project -> Import Projectand select the newly unzipped folder -> press OK.It will build the Gradle automatically.

在 Github 中单击要导入的项目的“克隆或下载”按钮 --> 下载 ZIP 文件并解压。在 Android Studio 中转到 File -> New Project -> Import Project并选择新解压的文件夹 -> 按 OK。它将自动构建 Gradle。

Good Luck with your project

祝你的项目好运

回答by Shubham Sethi

Steps:

脚步:

  1. Download the Zip from the website or clone from Github Desktop. Don't use VCS in android studio.
  2. (Optional)Copy the folder extracted into your AndroidStudioProjects folder which must contain the hidden .git folder.
  3. Open Android Studio-> File-> Open-> Select android directory.
  4. If it's a Eclipse project then convert it to gradle(Provided by Android Studio). Otherwise, it's done.
  1. 从网站下载 Zip 或从 Github Desktop 克隆。不要在 android studio 中使用 VCS。
  2. (可选)将提取的文件夹复制到您的 AndroidStudioProjects 文件夹中,该文件夹必须包含隐藏的 .git 文件夹。
  3. 打开Android Studio->文件->打开->选择android目录。
  4. 如果是 Eclipse 项目,则将其转换为 gradle(由 Android Studio 提供)。否则,它就完成了。