现在如何将 Eclipse 项目导入 Android Studio? [英] How do you import an Eclipse project into Android Studio now?

查看:36
本文介绍了现在如何将 Eclipse 项目导入 Android Studio?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android Studio 中为 Eclipse 项目使用导入项目",用于更改项目结构并生成 Gradle 文件,但现在(我使用的是 AS 0.5.3)它只生成 IDEA 文件(.iml、.idea) 但不是 Gradle,它也没有触及文件结构.

Using "Import Project" in Android Studio for an Eclipse project used to change the project structure and generate Gradle files, but right now (I'm using AS 0.5.3) it's only generating IDEA files (.iml, .idea) but not Gradle and it's not touching the file structure either.

现在如何将 Eclipse 项目导入 Android Studio?

How do you import an Eclipse project into Android Studio now?

更新:尝试在 Eclipse 中导出 gradle 文件不会为应用导出它们,它也不会在 Android Studio 中显示为模块.

Update: Trying to export gradle files in Eclipse won't export them for the app, it doesn't show up as a module in Android Studio either.

推荐答案

在较新版本的 Android Studio 中,引入 Eclipse/ADT 的最佳方式 (Android 开发工具) 项目是将其直接导入 Android Studio;我们曾经建议您先将其从 Eclipse 导出到 Gradle,但我们更新 ADT 的频率不足以跟上 Android Studio 的步伐.

In newer versions of Android Studio, the best way to bring in an Eclipse/ADT (Android Development Tool) project is to import it directly into Android Studio; we used to recommend you export it from Eclipse to Gradle first, but we haven't been updating ADT often enough to keep pace with Android Studio.

无论如何,如果您在启动 Android Studio 时从文件"菜单或欢迎"屏幕中选择导入项目",它应该会引导您完成一个专门的向导,提示您它打算将文件复制到新的目录结构而不是就地导入它们,它将提供修复一些常见问题,例如将依赖项转换为 Maven 样式的包含等.

In any event, if you choose "Import Project" from the File menu or from the Welcome screen when you launch Android Studio, it should take you through a specialized wizard that will prompt you that it intends to copy the files into a new directory structure instead of importing them in-place, and it will offer to fix up some common things like converting dependencies into Maven-style includes and such.

您似乎没有获得这种专门的流程.我认为它可能不会将您导入的项目识别为 ADT 项目,并且默认为不了解 Gradle 的旧的内置 IntelliJ 行为.要使专门的导入工作,必须满足以下条件:

It doesn't seem like you're getting this specialized flow. I think it may not be recognizing your imported project as an ADT project, and it's defaulting to the old built-into-IntelliJ behavior which doesn't know about Gradle. To get the specialized import working, the following must be true:

  • 您导入的项目的根目录必须有一个 AndroidManifest.xml 文件.
  • 或者:
    • 根目录必须包含来自 Eclipse 的 .project.classpath 文件
    • The root directory of the project you import must have an AndroidManifest.xml file.
    • Either:
      • The root directory must contain the .project and .classpath files from Eclipse
      • 根目录必须包含ressrc 目录.
      • The root directory must contain res and src directories.

      如果您的项目很复杂,也许您没有将其指向它希望成功导入的根目录.

      If your project is complex, perhaps you're not pointing it as the root directory it wants to see for the import to succeed.

      这篇关于现在如何将 Eclipse 项目导入 Android Studio?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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