I've imported a project to Android Studio with several subprojects.
我已经将一个项目导入Android Studio,并有几个子项目。
I want to run a subproject.
我想运行一个子项目。
I successfully make'd this subprojects build.gradle as a module.
我成功地构建了这个子项目。它作为一个模块。
In order to run it, I went to Run > edit configurations > + > Android Application.
为了运行它,我运行了>编辑配置> + > Android应用程序。
Problem: When I try to select a module, none show up in the drop down list.
问题:当我尝试选择一个模块时,没有一个显示在下拉列表中。
Why is this?
这是为什么呢?
EDIT: it shows up as a module under Groovy but not under Android Application. How do I get it to show up under Android Application?
编辑:它显示为Groovy下的一个模块,而不是Android应用程序下的一个模块。如何让它在Android应用程序下显示?
20 个解决方案
#1
96
Make sure your build.gradle is
确保您的构建。gradle是
apply plugin: 'com.android.application'
not
不
apply plugin: 'com.android.library'
After you have changed, please sync your gradle again.
更改后,请重新同步您的等级。
#2
41
I fixed this by adding facets in Module settings. They were missing. right click on project > open Module settings > Facets > Add facets ( "+" sign at the top ) > Android. After adding facets you will have modules.
UPDATE:
For latest version of gradle, Facets have been removed, you can directly add modules now. right click on project > open Module settings > Add module ( "+" sign at the top ) > Phone and Tablet Application (Now you can create a new module and configure it).
我通过在模块设置中添加facet来解决这个问题。他们失踪。右键点击项目>打开模块设置> facet >添加facet(顶部为“+”标志)> Android添加facet之后,您将拥有模块。更新:对于最新版本的gradle, facet已经被删除,现在可以直接添加模块。右键点击项目>打开模块设置>添加模块(顶部“+”标志)>手机和平板应用程序(现在您可以创建一个新模块并配置它)。
#3
30
I had similar issue when I selected parent directory of my project, I resolved by Close Project -> Delete Project from Android Studio -> Import Project by selecting right build.gradle file.
我在选择项目的父目录时遇到了类似的问题,我通过Close project -> Delete project从Android Studio -> Import project选择了right build来解决。gradle文件。
Make sure you select right build.gradle file while import.
确保您选择了正确的构建。gradle文件导入。
#4
12
goto Android >> Gradle Scripts>>Build Gradle(Module :app)
goto Android >>等级脚本>>构建等级(模块:app)
make sure the first line of this file is like this.
确保这个文件的第一行是这样的。
apply plugin: 'com.android.application'
not like this
不喜欢这
apply plugin: 'com.android.library'
#5
11
I have tried all the options with no luck. So I have ended up with my working solution. Just make following steps:
我尝试了所有的选择,但都没有成功。所以我得到了有效解。把下面的步骤:
- Close android studio if open.
- 关闭安卓工作室。
- Copy module(project) in your current workspace.
- 复制当前工作区中的模块(项目)。
- Start android studio.
- 启动android工作室。
- You will see added module in project structure.
- 您将在项目结构中看到添加的模块。
- Open
settings.gradle
of your project andinclude ':YOUR_MODULE_NAME'
. - 打开设置。项目的等级,包括“:YOUR_MODULE_NAME”。
- Sync gradle and you can see module is successfully added to your project.
- 同步渐变,你可以看到模块被成功添加到你的项目中。
#6
5
This worked for me: File > Project Structure... > Modules > Green Plus Symbol > Import > Then Select The Project
这对我很有效:文件>项目结构…>模块> Green +符号>导入>,然后选择项目
#7
4
In your module build.gradle file make sure you have the correct plugin set. it should be
在您的模块构建。渐变文件确保你有正确的插件集,它应该是
apply plugin: 'android'
#8
3
This mainly happens when you copy a library project and try to build it. The solution would be to add
这主要发生在您复制一个库项目并尝试构建它时。解决办法是增加
apply plugin: 'com.android.application'
in the build.gradle file, instead of
在构建。gradle文件,而不是
apply plugin: 'com.android.library'
Then do a gradle sync
然后进行一级同步
#9
2
It was fixed for me after removing and re-adding the Android and Android-Gradle Facets in the Module Settings dialog.
在模块设置对话框中删除和重新添加Android和Android- gradle方面后,我修复了它。
#10
2
It appears different solutions work for difference people, for me just closing the project and importing it again resolved the problem.
似乎不同的人可以使用不同的解决方案,对我来说,仅仅关闭项目并导入它就解决了问题。
#11
2
The following worked for me:
以下是我的工作经验:
- edit the overall project's 'settings.gradle' file and add a line at the bottom to include your new module (include ':myNewModule')
- 编辑整个项目的设置。渐变文件,并在底部添加一行,以包含您的新模块(包括':myNewModule')
- Synch gradle.
- gradle同步。
- Add a build.gradle file into your new module directory. You need to make sure the first line says 'apply plugin: 'com.android.application'. Simply copying a build.gradle from another module in your project, if you have one, seems to work.
- 添加一个构建。渐变文件到您的新模块目录。你需要确保第一行写着“应用插件:com.android.application”。简单地复制一个构建。如果你的项目中有一个模块,那么来自另一个模块的gradle似乎可以工作。
- Synch Gradle
- 同步Gradle
- Your module should now show up in 'Edit Configurations'
- 模块现在应该显示在“编辑配置”中
#12
2
I finally figure out why the module is not showed up when I add configuration for AndroidTests for a com.android.library
module.
我终于弄明白为什么在为com.android添加android测试的配置时没有显示模块。库模块。
If you include your library module in your application's build.gradle
like this:
如果您将库模块包含在应用程序的构建中。它是这样的:
compile project(':yourlibrary')
Since for library module it is compiled with release
mode by default, you can't run Android Tests
for it, that's why it won't show up in the module list. I fixed it with following modification:
由于库模块默认使用发布模式编译,因此无法运行Android测试,所以它不会出现在模块列表中。我修正如下:
Add following configuration to the build.gradle
of your library module:
向构建中添加以下配置。图书馆模块的等级:
publishNonDefault true
By make following changes, you can debug
compile your library by editing the build.gradle
of your application module like following:
通过进行以下更改,您可以通过编辑构建来调试编译库。应用模块的等级如下:
- compile project(':yourlibrary')
+ debugCompile project(path: ':yourlibrary', configuration: 'debug')
+ releaseCompile project(path: ':yourlibrary', configuration: 'release')
Then sync it and you'll find it shows in the list.
然后同步它,你会发现它显示在列表中。
#13
1
I added this line to my app.iml file and it works
我将这一行添加到我的app.iml文件中,它就可以工作了
orderEntry type="library" exported="" name="appcompat-v7-19.1.0" level="project" />
orderEntry类型="library" export ="" " name="appcompat-v7-19.1.0" level="project" />
#14
1
I managed to fix it in Android Studio 1.3.1 by doing the following:
通过以下操作,我在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 - 从现有库模块复制.iml文件,并更改文件的名称,并在.iml文件中重命名引用
- Add the module name to settings.gradle
- 将模块名添加到settings.gradle
- Add the module dependency in your app's build.gradle file 'compile project(':mylibrary')'
- 在应用程序的构建中添加模块依赖项。gradle文件编译项目(':mylibrary ')'
- Close and reopen Android Studio
- 关闭并重新打开Android Studio
- Verify that Android Studio recognises the module as a library (should be bold)
- 验证Android Studio将模块识别为库(应该是粗体)
- Rename module's directory and module name by right clicking on the newly created module.
- 通过右键单击新创建的模块,重命名模块的目录和模块名。
- Enjoy :)
- 享受:)
#15
1
For me it was fixed by simply restarting Android Studio.. Like the good old days of Eclipse
对我来说,只要重新启动Android Studio就可以解决这个问题。就像旧日月食一样
#16
0
Sometimes the errors exists in Android-manifest because of that there is cross like image over run/debug configuration hence try to look over if Android-manifest has any errors in just case.
有时Android-manifest中存在错误,因为在运行/调试配置中存在交叉的图像,所以尽量检查Android-manifest是否存在错误。
#17
0
For my case, a newbie I boogered up my project, not sure how but it would not longer run and complained about the manifest, the R, everything. I realized that some how in my settings.gradle did not have include ':app'
once I added this, I was back on my way.
就我的情况而言,一个新手把我的项目搞砸了,不知道该怎么做,但它不会再运行了,并抱怨清单,R,所有的一切。我意识到一些如何在我的设置。gradle没有包括“:应用程序”,一旦我添加了这个,我就回到了我的路上。
#18
0
Well, nothing worked for me from all the answers. Finally, I clicked Run > Edit Configuration. On the left, u can choose a new main module and remove to deleted ones.
好吧,所有的答案对我都不起作用。最后,我单击Run >编辑配置。在左边,u可以选择一个新的主模块并删除到已删除的模块。
#19
0
Add your module in your applications .iml file like:
在应用程序中添加模块。iml文件如下:
orderEntry type="module" module-name="yourmoudlename" exported=""
It works for me.
它适合我。
#20
-2
These types of problems are related to AndroidManifest.xml, so check the bugs thats are in AndroidManifest file.
这些类型的问题与AndroidManifest有关。xml,因此检查在AndroidManifest文件中的bug。
#1
96
Make sure your build.gradle is
确保您的构建。gradle是
apply plugin: 'com.android.application'
not
不
apply plugin: 'com.android.library'
After you have changed, please sync your gradle again.
更改后,请重新同步您的等级。
#2
41
I fixed this by adding facets in Module settings. They were missing. right click on project > open Module settings > Facets > Add facets ( "+" sign at the top ) > Android. After adding facets you will have modules.
UPDATE:
For latest version of gradle, Facets have been removed, you can directly add modules now. right click on project > open Module settings > Add module ( "+" sign at the top ) > Phone and Tablet Application (Now you can create a new module and configure it).
我通过在模块设置中添加facet来解决这个问题。他们失踪。右键点击项目>打开模块设置> facet >添加facet(顶部为“+”标志)> Android添加facet之后,您将拥有模块。更新:对于最新版本的gradle, facet已经被删除,现在可以直接添加模块。右键点击项目>打开模块设置>添加模块(顶部“+”标志)>手机和平板应用程序(现在您可以创建一个新模块并配置它)。
#3
30
I had similar issue when I selected parent directory of my project, I resolved by Close Project -> Delete Project from Android Studio -> Import Project by selecting right build.gradle file.
我在选择项目的父目录时遇到了类似的问题,我通过Close project -> Delete project从Android Studio -> Import project选择了right build来解决。gradle文件。
Make sure you select right build.gradle file while import.
确保您选择了正确的构建。gradle文件导入。
#4
12
goto Android >> Gradle Scripts>>Build Gradle(Module :app)
goto Android >>等级脚本>>构建等级(模块:app)
make sure the first line of this file is like this.
确保这个文件的第一行是这样的。
apply plugin: 'com.android.application'
not like this
不喜欢这
apply plugin: 'com.android.library'
#5
11
I have tried all the options with no luck. So I have ended up with my working solution. Just make following steps:
我尝试了所有的选择,但都没有成功。所以我得到了有效解。把下面的步骤:
- Close android studio if open.
- 关闭安卓工作室。
- Copy module(project) in your current workspace.
- 复制当前工作区中的模块(项目)。
- Start android studio.
- 启动android工作室。
- You will see added module in project structure.
- 您将在项目结构中看到添加的模块。
- Open
settings.gradle
of your project andinclude ':YOUR_MODULE_NAME'
. - 打开设置。项目的等级,包括“:YOUR_MODULE_NAME”。
- Sync gradle and you can see module is successfully added to your project.
- 同步渐变,你可以看到模块被成功添加到你的项目中。
#6
5
This worked for me: File > Project Structure... > Modules > Green Plus Symbol > Import > Then Select The Project
这对我很有效:文件>项目结构…>模块> Green +符号>导入>,然后选择项目
#7
4
In your module build.gradle file make sure you have the correct plugin set. it should be
在您的模块构建。渐变文件确保你有正确的插件集,它应该是
apply plugin: 'android'
#8
3
This mainly happens when you copy a library project and try to build it. The solution would be to add
这主要发生在您复制一个库项目并尝试构建它时。解决办法是增加
apply plugin: 'com.android.application'
in the build.gradle file, instead of
在构建。gradle文件,而不是
apply plugin: 'com.android.library'
Then do a gradle sync
然后进行一级同步
#9
2
It was fixed for me after removing and re-adding the Android and Android-Gradle Facets in the Module Settings dialog.
在模块设置对话框中删除和重新添加Android和Android- gradle方面后,我修复了它。
#10
2
It appears different solutions work for difference people, for me just closing the project and importing it again resolved the problem.
似乎不同的人可以使用不同的解决方案,对我来说,仅仅关闭项目并导入它就解决了问题。
#11
2
The following worked for me:
以下是我的工作经验:
- edit the overall project's 'settings.gradle' file and add a line at the bottom to include your new module (include ':myNewModule')
- 编辑整个项目的设置。渐变文件,并在底部添加一行,以包含您的新模块(包括':myNewModule')
- Synch gradle.
- gradle同步。
- Add a build.gradle file into your new module directory. You need to make sure the first line says 'apply plugin: 'com.android.application'. Simply copying a build.gradle from another module in your project, if you have one, seems to work.
- 添加一个构建。渐变文件到您的新模块目录。你需要确保第一行写着“应用插件:com.android.application”。简单地复制一个构建。如果你的项目中有一个模块,那么来自另一个模块的gradle似乎可以工作。
- Synch Gradle
- 同步Gradle
- Your module should now show up in 'Edit Configurations'
- 模块现在应该显示在“编辑配置”中
#12
2
I finally figure out why the module is not showed up when I add configuration for AndroidTests for a com.android.library
module.
我终于弄明白为什么在为com.android添加android测试的配置时没有显示模块。库模块。
If you include your library module in your application's build.gradle
like this:
如果您将库模块包含在应用程序的构建中。它是这样的:
compile project(':yourlibrary')
Since for library module it is compiled with release
mode by default, you can't run Android Tests
for it, that's why it won't show up in the module list. I fixed it with following modification:
由于库模块默认使用发布模式编译,因此无法运行Android测试,所以它不会出现在模块列表中。我修正如下:
Add following configuration to the build.gradle
of your library module:
向构建中添加以下配置。图书馆模块的等级:
publishNonDefault true
By make following changes, you can debug
compile your library by editing the build.gradle
of your application module like following:
通过进行以下更改,您可以通过编辑构建来调试编译库。应用模块的等级如下:
- compile project(':yourlibrary')
+ debugCompile project(path: ':yourlibrary', configuration: 'debug')
+ releaseCompile project(path: ':yourlibrary', configuration: 'release')
Then sync it and you'll find it shows in the list.
然后同步它,你会发现它显示在列表中。
#13
1
I added this line to my app.iml file and it works
我将这一行添加到我的app.iml文件中,它就可以工作了
orderEntry type="library" exported="" name="appcompat-v7-19.1.0" level="project" />
orderEntry类型="library" export ="" " name="appcompat-v7-19.1.0" level="project" />
#14
1
I managed to fix it in Android Studio 1.3.1 by doing the following:
通过以下操作,我在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 - 从现有库模块复制.iml文件,并更改文件的名称,并在.iml文件中重命名引用
- Add the module name to settings.gradle
- 将模块名添加到settings.gradle
- Add the module dependency in your app's build.gradle file 'compile project(':mylibrary')'
- 在应用程序的构建中添加模块依赖项。gradle文件编译项目(':mylibrary ')'
- Close and reopen Android Studio
- 关闭并重新打开Android Studio
- Verify that Android Studio recognises the module as a library (should be bold)
- 验证Android Studio将模块识别为库(应该是粗体)
- Rename module's directory and module name by right clicking on the newly created module.
- 通过右键单击新创建的模块,重命名模块的目录和模块名。
- Enjoy :)
- 享受:)
#15
1
For me it was fixed by simply restarting Android Studio.. Like the good old days of Eclipse
对我来说,只要重新启动Android Studio就可以解决这个问题。就像旧日月食一样
#16
0
Sometimes the errors exists in Android-manifest because of that there is cross like image over run/debug configuration hence try to look over if Android-manifest has any errors in just case.
有时Android-manifest中存在错误,因为在运行/调试配置中存在交叉的图像,所以尽量检查Android-manifest是否存在错误。
#17
0
For my case, a newbie I boogered up my project, not sure how but it would not longer run and complained about the manifest, the R, everything. I realized that some how in my settings.gradle did not have include ':app'
once I added this, I was back on my way.
就我的情况而言,一个新手把我的项目搞砸了,不知道该怎么做,但它不会再运行了,并抱怨清单,R,所有的一切。我意识到一些如何在我的设置。gradle没有包括“:应用程序”,一旦我添加了这个,我就回到了我的路上。
#18
0
Well, nothing worked for me from all the answers. Finally, I clicked Run > Edit Configuration. On the left, u can choose a new main module and remove to deleted ones.
好吧,所有的答案对我都不起作用。最后,我单击Run >编辑配置。在左边,u可以选择一个新的主模块并删除到已删除的模块。
#19
0
Add your module in your applications .iml file like:
在应用程序中添加模块。iml文件如下:
orderEntry type="module" module-name="yourmoudlename" exported=""
It works for me.
它适合我。
#20
-2
These types of problems are related to AndroidManifest.xml, so check the bugs thats are in AndroidManifest file.
这些类型的问题与AndroidManifest有关。xml,因此检查在AndroidManifest文件中的bug。