Java 在模块中找不到 Android Facet

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21669652/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 09:59:50  来源:igfitidea点击:

No Android Facet Found in Module

javaandroidandroid-studioandroid-gradle-plugin

提问by rhodysurf

I just switched to Android-Studio from Eclipse. I am trying to run my application after setting up the gradle files. The project builds with no errors, however I can not run my app because there are no android facets found.

我刚刚从 Eclipse 切换到 Android-Studio。我试图在设置 gradle 文件后运行我的应用程序。该项目构建时没有错误,但是我无法运行我的应用程序,因为没有找到 android facet。

enter image description here

在此处输入图片说明

When I go to project structure there are no facets and I do not see any way to add a facet. How can I run my application?

当我进入项目结构时,没有方面,我看不到任何添加方面的方法。如何运行我的应用程序?

enter image description here

在此处输入图片说明

采纳答案by Heinrisch

I solved it by removing the .idea folder and any .iml files and then re-import the project into Android Studio.

我通过删除 .idea 文件夹和任何 .iml 文件解决了这个问题,然后将项目重新导入到 Android Studio 中。

If after importing you end up with the error No facet found in moduleyou need to follow this steps

如果导入后出现错误No facet found in module你需要按照以下步骤操作

Go to Run/Edit Configurationsand you will see at lest two configurations one with the name of the original name my project: lets call it helloWordand another called app

转到Run/Edit Configurations,您将看到至少两个配置,一个是我的项目的原始名称:我们称之为helloWord,另一个名为app

The one with the original name helloWordwas having this problem, but the configuration called appworked fine (I was able to run it)

原名 helloWord有这个问题,但名为app的配置工作正常(我能够运行它)

So delete the setting with the facet problem helloWordand renamed the one called appback to the name of my project helloWord

因此,删除具有方面问题helloWord的设置,并将名为app的设置重命名回我的项目helloWord的名称

回答by rhodysurf

Th solution for me was to create a new project in android-studio. Then, copy over the code, resources, and dependencies to the new project. Then finally update the Gradle files manually and sync. Not perfect, but it worked and I can now upload to my device.

我的解决方案是在 android-studio 中创建一个新项目。然后,将代码、资源和依赖项复制到新项目中。然后最后手动更新 Gradle 文件并同步。不完美,但它有效,我现在可以上传到我的设备。

EDIT: This works but the method marked as the answer is what I was looking for.

编辑:这有效,但标记为答案的方法正是我正在寻找的。

回答by Shayan Amani

I just solved my problem with the following steps, walk through with me:

我刚刚通过以下步骤解决了我的问题,请与我一起完成:

1) File-> Project Structure, or press (Ctrl+Alt+Shift+S) shortcut to open "Project Structure".

2) Select Facetswhich is under the ProjectSettingstab. (First column)

3) Click on +button which is at the top of the Second Column to add new facets.

4) Select Androidfacet from that Addmenu which will prompt another dialog box to select a module. (Select a module to which you want to apply this facet).

5) Select your module and that's it.

1) File-> Project Structure,或按 ( Ctrl+ Alt+ Shift+ S) 快捷键打开“项目结构”。

2)在Project Settings选项卡下选择Facets。(第一栏)

3) 单击第二列顶部的+按钮以添加新方面。

4)从添加菜单中选择Androidfacet,这将提示另一个对话框来选择一个模块。(选择要应用此构面的模块)。

5)选择你的模块,就是这样。

Happy Coding!! ;)

快乐编码!!;)

回答by deepThought

Invalidate cache and restart worked for me.

使缓存无效并重新启动对我有用。