如何在 Android Studio 中从 GitHub 打开项目?Maven 和 android 支持库的问题. [英] How to open the project from GitHub in Android studio? Troubles with Maven and android support libraries.

查看:25
本文介绍了如何在 Android Studio 中从 GitHub 打开项目?Maven 和 android 支持库的问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用 Android Studio.我想从 GitHub 打开项目https://github.com/TonicArtos/StickyGridHeaders

在第一个屏幕上,我单击从版本控制检出"、GitHub",选择磁盘上的位置.克隆后我有一个问题你已经签出一个 Android Studio 项目文件......你想打开它吗?",我同意.比我同意自动导入 Maven 项目.比我找到项目示例",尝试构建它并获得找不到与给定名称主题匹配的资源:AppCompat",然后导入 android.support.v7.app.ActionBarActivity 不起作用.

https://www.dropbox.com/s/ph04ogcr2txmge3/Screenshot%202014-07-24%2017.42.22.png

如何制作示例应用程序?要求是保存项目结构以使用 'git status' 和 'git diff' 命令.

解决方案

关于这个主题有几个 SO 问题,但@MartinRevert 的回答 (https://stackoverflow.com/a/24978323/5025060) 是我发现的唯一一个提到 Android Studio (AS) 的 Gradle 依赖项.如果 Github 项目是用 Eclipse 构建的,将其导入 AS 可以工作,但结果将无法用 AS 构建(说明:项目的制作项目"图标在 AS 中变灰).>

基于 Martin 的回答,并使用 IntelliJ 的 Migrating From Eclipse Projects 页面作为参考,我找到了一种简单透明的方法将基于 Eclipse 的 Github 项目导入到 AS 2.1.2 中:

  1. 使用AS导入Github项目:File->New->Project from Version Control->Github这会克隆 Github 项目,但如果它不是 Gradle 项目(见上文),请执行以下附加步骤:
  2. 使用以下命令创建一个新项目:File->New->Import Project 并单击您在上述步骤 (1) 中存储项目的文件夹.接受所有默认设置,AS 会将 Eclipse 项目导入"到 Gradle 项目,现在可以构建该项目.
  3. 您现在可以删除(使用本机目录删除工具)您在上面 (1) 中创建的项目.

相关问题:

I'm starting to use Android Studio. I'd like to open project from GitHub https://github.com/TonicArtos/StickyGridHeaders

On first screen I click 'Check out from Version Control', 'GitHub', select place on disk. After cloning I have a question 'You have checked out an Android Studio project file… Would you like to open it?', I agree. Than I agree to auto-import for Maven project. Than I find the project 'Examples', try to build it and get 'No resource found that matches the given name Theme:AppCompat', and import android.support.v7.app.ActionBarActivity does not work.

https://www.dropbox.com/s/ph04ogcr2txmge3/Screenshot%202014-07-24%2017.42.22.png

What to do to make the example app? Requirement is to save the project structure for using 'git status' and 'git diff' commands.

解决方案

There are several SO questions on this topic, but @MartinRevert's answer (https://stackoverflow.com/a/24978323/5025060) is the only one I found mentioning Android Studio's (AS's) Gradle dependency. If the Github project was built with Eclipse, importing it to AS will work but the result will not be buildable with AS (indication: the project's "Make project" icon is grayed out in AS).

Building on Martin's answer, and using IntelliJ's Migrating From Eclipse Projects page as a reference, I found a simple and transparent way to import an Eclipse-based Github project into AS 2.1.2:

  1. Import the Github project using AS: File->New->Project from Version Control->Github This clones the Github project, but if it is not a Gradle Project (see above), follow these additional steps:
  2. Create a new project using: File->New->Import Project and click on the folder you stored the project to in step (1) above. Accept all of the defaults and AS will "import" the Eclipse project to a Gradle project which it will now be able to build.
  3. You may now delete (using a native directory removal tool) the project you created in (1) above.

Related questions:

这篇关于如何在 Android Studio 中从 GitHub 打开项目?Maven 和 android 支持库的问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆