且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android Studio - 如何在单个窗口中打开多个项目?

更新时间:2023-09-18 23:36:52

在 Android Studio/IntelliJ IDEA 中无法在单个窗口中打开两个项目.因此,当您打开第二个项目时,您必须做出决定:

Open two projects in a single window is not possible in Android Studio / IntelliJ IDEA. So, when you open a second project, you'll have to decide:

新项目可以在新窗口中打开或替换现有窗口中的项目.您希望如何打开项目?

New projects can either be opened in a new window or replace the project in the existing window. How would you like to open the project?

此限制很有用,因为您的窗口提供了特定于项目的功能,例如 VCS 信息的更改"选项卡等.

This limitation is useful because your window offers project specific features, like the Changes tab for VCS information, etc.

现在,您可以将库项目复制到您的项目文件夹中,并将其声明为模块依赖项.如果您在不同的项目中使用相同的库,您最终将拥有多次代码.

For now, you can copy the library project into your project folder and declare it as a module dependency. If you use the same libraries in different projects, you will end up having the code multiple times.

ProjectA                   ProjectB
 facebook-sdk/              actionbarsherlock/
 actionbarsherlock/         bin/
 bin/                       src/
 src/                       ...
 AndroidManifest.xml

虽然这感觉有点不方便,但它有助于在 VCS 中拥有所有必需的源.很快,Gradle,新的构建系统,将愉快地管理这些依赖项.以下是 Gradle 构建如何包含 ActionBarSherlock 或类似库的示例:

While this feels kind of inconvenient, it helps having all the required sources in VCS. Soon, Gradle, the new build system, will manage these dependencies pleasantly. Here's an example of how the Gradle build could look like to include ActionBarSherlock or similar libs:

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.actionbarsherlock:library:4.2.0'
}

此答案中,您会找到此解决方案尚未奏效的一些原因.

In this answer you'll find some reasons why this solution does not work yet.