创建或导入项目
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android Studio for Platform (ASfP) 可帮助您为 Android 开源项目 (AOSP) 设置开发环境。本页介绍了如何启动新项目或导入现有项目。
创建一个新项目
如果您未打开任何项目,请在欢迎屏幕上点击 New Project。
如果您已打开项目,请从菜单中依次选择 ASfP > Project > New Project。
在向导中填写项目配置详细信息:
- 模块路径:指定 AOSP 源代码检出根目录的绝对路径(例如
/path/to/aosp
)。
- Lunch 目标:输入您用于构建的 lunch 目标(例如
aosp_arm64-eng
)。
- 项目名称:为您的项目提供一个描述性名称。
- 目录 / 模块:列出您要包含在项目中的初始目录或模块,以英文逗号分隔。这些路径应是相对于代码库根目录的相对路径(例如
frameworks/base,
packages/apps/Settings
)。您可以稍后添加更多路径或优化此选择。
点击 Finish。ASfP 会创建项目结构和 .asfp-project
配置文件。
完成初始项目设置后,您可以通过修改项目根目录中的 .asfp-project
文件来进一步自定义项目。此文件可让您:
- 添加或移除目录和模块。
- 启用对其他语言(如 Rust 或 C++)的支持。
- 配置 build 标志和环境变量。
- 指定测试来源。
如需详细了解所有配置选项,请参阅项目概览。修改 .asfp-project
后,您需要同步项目,更改才能生效。
导入现有项目
ASfP 没有单独的“导入”操作。如需打开现有的 ASfP 项目配置,请执行以下操作:
- 依次选择 ASfP > Project > New Project。
- 在项目名称字段中,找到并选择包含要打开的现有
.asfp-project
文件的目录。向导中的字段将根据所选 .asfp-project
文件进行填充。
- 点击 Finish。ASfP 会打开并为项目编制索引。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-09-04。
[null,null,["最后更新时间 (UTC):2025-09-04。"],[],[],null,["Android Studio for Platform (ASfP) helps you set up your development environment\nfor the [Android Open Source Project (AOSP)](https://source.android.com/). This page explains how to\nstart a new project or import an existing one.\n\nCreate a new project\n\n1. If you don't have a project open, click **New Project** on the Welcome\n screen.\n\n2. If you already have a project open, select **ASfP \\\u003e Project \\\u003e New Project**\n from the menu.\n\n3. Fill in the project configuration details in the wizard:\n\n - **Module paths:** Specify the absolute path to the root of your AOSP source code checkout (for example, `/path/to/aosp`).\n - **Lunch target:** Enter the lunch target you use for building (for example, `aosp_arm64-eng`).\n - **Project name:** Give your project a descriptive name.\n - **Directories / modules:** List the initial directories or modules you want to include in your project, separated by commas. These should be relative paths from the repository root (for example, `frameworks/base,\n packages/apps/Settings`). You can add more or refine this selection later.\n4. Click **Finish** . ASfP creates the project structure and the `.asfp-project`\n configuration file.\n\nConfigure and customize your project\n\nAfter the initial project setup, you can further customize your project by\nediting the `.asfp-project` file located in the project root. This file lets\nyou:\n\n- Add or remove directories and modules.\n- Enable support for other languages like Rust or C++.\n- Configure build flags and environment variables.\n- Specify test sources.\n\nFor detailed information on all configuration options, see the [Projects\noverview](/studio/platform/projects). After editing `.asfp-project`, you'll need to sync the project for\nthe changes to take effect.\n\nImport an existing project\n\nASfP doesn't have a separate \"import\" action. To open an existing ASfP project\nconfiguration:\n\n1. Select **ASfP \\\u003e Project \\\u003e New Project**.\n2. In the **Project Name** field, navigate to and select the directory containing the existing `.asfp-project` file you want to open. The fields in the wizard will populate based on the selected `.asfp-project` file.\n3. Click **Finish**. ASfP opens and indexes the project."]]