更新时间:2022-10-31 19:53:14
关于这个主题有几个 SO 问题,但@MartinRevert 的回答 (https://***.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 中:
File->New->Project from Version Control->Github
这会克隆 Github 项目,但如果它不是 Gradle 项目(见上文),请执行以下附加步骤:File->New->Import Project
并单击您在上述步骤 (1) 中存储项目的文件夹.接受所有默认设置,AS 会将 Eclipse 项目导入"到 Gradle 项目,现在可以构建该项目.相关问题:
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://***.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:
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: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.Related questions: