如何将android源代码(AOSP)导入Android studio?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24531006/
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
How to import android source code(AOSP) into Android studio?
提问by cowboi-peng
I know how to import android source code into eclipse , but is there any way to import android source code into android studio.because i want to change my ide from eclipse to android studio . thanks in advance!
我知道如何将 android 源代码导入到 eclipse 中,但是有什么方法可以将 android 源代码导入到 android studio 中。因为我想将我的 ide 从 eclipse 更改为 android studio。提前致谢!
采纳答案by cowboi-peng
I found the answer from my colleague, he told me that , use the file in sourcecode/development/ide/eclipse/.classpath . this file is for eclipse to import android source code . but there is a way to transfer this file into a intellij project import file . sorry , I also don't know how to transfer. but my colleague email me a *.iml file.yeah ,this is the file that can help you crate the intellij module . After you get the file ,copy that *.iml file to the root of your sourcecode,then you can open the intellij,create a empty project ,import module from existing module ,then in the window ,chose the *.iml file ,after that ,the only thing you can do is wait . it takes much time to import it. so ,you can develop the android source code in intellij . enjoy it!
我从我的同事那里找到了答案,他告诉我,使用 sourcecode/development/ide/eclipse/.classpath 中的文件。该文件用于 eclipse 导入 android 源代码。但是有一种方法可以将此文件传输到 Intellij 项目导入文件中。不好意思,我也不知道怎么转。但是我的同事给我发了一个 *.iml 文件。是的,这是可以帮助您创建 intellij 模块的文件。获取文件后,将该 *.iml 文件复制到源代码的根目录,然后您可以打开 Intellij,创建一个空项目,从现有模块导入模块,然后在窗口中,选择 *.iml 文件,之后那,你唯一能做的就是等待。导入它需要很多时间。所以,你可以在intellij中开发android源代码。好好享受!
回答by wseme
I know this was already answered, but I wanted to add onto this for anyone else that sees this.
我知道这已经得到了回答,但我想为其他看到这个的人添加这个。
For Android studio:
对于安卓工作室:
Open terminal (*nix system) call the following:
{AOSP root}/make idegen && development/tools/idegen/idegen.sh
This will generate an
android.ipr
file in the{AOSP root}
directory.- In Android Studio, select 'Open project' and select the generated
android.ipr
file. - Note: this will take a long time to index all the files (~2 hours). Be patient. If a dialog box that says 'Framework detected' appears, select that and hit 'OK'.
打开终端(*nix 系统)调用以下命令:
{AOSP root}/make idegen && development/tools/idegen/idegen.sh
这将
android.ipr
在{AOSP root}
目录中生成一个文件。- 在 Android Studio 中,选择“打开项目”并选择生成的
android.ipr
文件。 - 注意:索引所有文件需要很长时间(约 2 小时)。要有耐心。如果出现显示“检测到框架”的对话框,请选择该对话框并点击“确定”。
Now you have the entire Android framework loaded into Android Studio.
现在您已将整个 Android 框架加载到 Android Studio 中。
回答by Himanshu Agarwal
Follow the steps to Migrate to Android Studio:
按照以下步骤迁移到 Android Studio:
Export from Eclipse
从 Eclipse 导出
- In Eclipse, select File > Export.
- In the window that appears, open Android and select Generate Gradle build files.
- Select the project you want to export for Android Studio and click Finish.
- 在 Eclipse 中,选择文件 > 导出。
- 在出现的窗口中,打开 Android 并选择生成 Gradle 构建文件。
- 选择要为 Android Studio 导出的项目,然后单击完成。
Import to Android Studio
导入到 Android Studio
- In Android Studio, close any projects currently open. You should see the Welcome to Android Studio window.
- Click Import Project.
- Locate the project you exported from Eclipse, expand it, select the build.gradle file and click OK.
- In the following dialog, leave Use gradle wrapper selected and click OK. (You do not need to specify the Gradle home.)
- 在 Android Studio 中,关闭当前打开的所有项目。您应该会看到欢迎使用 Android Studio 窗口。
- 单击导入项目。
- 找到您从 Eclipse 导出的项目,展开它,选择 build.gradle 文件并单击 OK。
- 在接下来的对话框中,选择 Use gradle wrapper 并单击 OK。(您不需要指定 Gradle 主页。)
That's all you need to do. For more you may refer to official doc.
这就是你需要做的。更多内容可以参考官方文档。