【问题标题】:How to import Android Studio Project from Git如何从 Git 导入 Android Studio 项目
【发布时间】:2014-02-27 18:17:33
【问题描述】:

我有一个我已经签入 git 的 android studio 项目。我的 git 忽略文件如下所示:

# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# Eclipse project files
.classpath
.project

# Proguard folder generated by Eclipse
proguard/

# Intellij project files
*.iws
.idea/workspace.xml
.idea/tasks.xml

/gradle

当我去我的笔记本电脑拉下项目时,我不确定是否应该在 android studio 中打开或导入以正确进入项目。当我打开时,我收到以下错误:

Cannot load module file 'D:\dev\android\projects\projectname\ProjectName.iml':
File D:\dev\android\projects\projectname\ProjectName.iml does not exist

即使该文件确实存在。

当我导入而不是打开 android studio 时,我会询问 gradle home 的路径,但我不确定要输入什么。我使用的是 android studio 0.4.3。

任何帮助将不胜感激。

答案:

我能够通过打开而不是导入来构建项目。然而,在这个过程中,intellij 在我的项目的根目录中创建了一个额外的 iml 文件,该文件在我的桌面上不存在。不知道为什么创建它以及是否需要它。我这辈子都想不出正确的方法将我的项目推送到 git 中,然后在另一台机器上恢复它,而不会导致生成大量新文件并破坏东西。

【问题讨论】:

  • 如果你把答案写在你如何修复并接受它会更好,这样我们可以直接看解决方案

标签: android github android-studio android-gradle-plugin


【解决方案1】:

使用导入和删除 .gitignore 中的“/gradle” 可以忽略 .gradle,但 /gradle 应该包含在 git 中。

至少这是我让它为我工作的方式。

【讨论】:

  • 导入时,选择 build.gradle 文件,如果有的话,让它使用包装器。我还建议将 .iml 和所有 .idea 添加到您的 .gitignore。
  • 我相信在几个版本之前 .iml 和 .idea 应该包含在提交给 git 的文件中。
  • 我重新添加了 gradle 文件夹,但我仍然遇到错误,当我尝试使用 import 时,它要求 gradle home 但无论我放入什么都说它无效。
【解决方案2】:

尝试是.gitignore 文件。

.gitignore

你不能导入项目是因为你的项目中有一些IDE生成的文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-19
    • 2014-08-19
    • 2016-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-13
    • 1970-01-01
    相关资源
    最近更新 更多