我已经导入了一个项目到Android工作室的几个子项目。

我想运行一个子项目。

我成功地完成了这个子项目的构建。Gradle作为一个模块。

为了运行它,我去运行>编辑配置> + > Android应用程序。

问题:当我尝试选择一个模块时,下拉列表中没有显示。

为什么会这样?

编辑:它在Groovy下显示为一个模块,但在Android应用程序下不显示。我如何让它显示在Android应用程序?


当前回答

如果以上都不起作用。尝试更新你的Android工作室版本。 步骤: 1. 在Android Studio中,选择文件>设置(或Android Studio >偏好在Mac上)。 2. 在左侧窗格中,选择“外观和行为”>“系统设置”>“更新”。 3.确保选中了“自动检查更新”,然后从下拉列表中选择一个频道。 4. 单击OK。

其他回答

我通过以下方法在Android Studio 1.3.1中修复了这个问题:

Make a new module from File -> New -> New Module Name it something different, e.g. 'My Libary' Copy an .iml file from an existing library module and change the name of the file and rename references in the .iml file Add the module name to settings.gradle Add the module dependency in your app's build.gradle file 'compile project(':mylibrary')' Close and reopen Android Studio Verify that Android Studio recognises the module as a library (should be bold) Rename module's directory and module name by right clicking on the newly created module. Enjoy :)

似乎不同的解决方案适用于不同的人,对我来说,只是关闭项目并重新导入就解决了问题。

这主要发生在复制一个库项目并试图构建它的时候。解决办法是

apply plugin: 'com.android.application'

在构建中。Gradle文件,而不是

apply plugin: 'com.android.library'

然后进行gradle同步

关闭所有Android Studio项目 在Android Studio向导中从最近的项目中删除该项目 重启Android Studio 使用导入选项(导入项目- Gradle, Eclipse ADT等)而不是打开现有的 项目AS项目 同步项目与gradle文件

下面的方法对我很有效:

编辑整个项目的设置。gradle文件,并在底部添加一行来包含你的新模块(包括':myNewModule') -例如:

include ':myNewModule'

gradle同步。 添加构建。Gradle文件到你的新模块目录。你需要确保第一行说'apply plugin: 'com.android.application'。简单地复制一个构建。Gradle来自你项目中的另一个模块,如果你有的话,似乎可以工作。 同步Gradle 您的模块现在应该显示在“编辑配置”中