java 运行时android studio应用程序中的红色X标记
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39197264/
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
Red X Mark in android studio application while running
提问by Yogesh Pandey
I wish if some one can help me in android studio problem?
我希望有人可以帮助我解决 android studio 问题吗?
I just came up while i was working on my application I have no idea whatsoever since i tried all possible solution that can resolve the issues.
我刚刚在处理我的应用程序时提出我不知道因为我尝试了可以解决问题的所有可能的解决方案。
Any help will be much appreciated.
任何帮助都感激不尽。
回答by TheAnonymous010
The red X is there saying you cannot build/run your project because it had an error while indexing your application. Sometimes that error occurs when you open a project. All it needs to do is index your code again. A couple things you can do to fix this:
红色 X 表示您无法构建/运行您的项目,因为它在为您的应用程序编制索引时出错。有时,当您打开项目时会发生该错误。它需要做的就是再次索引您的代码。您可以做几件事来解决这个问题:
- Go into your gradle file, delete something, and type it back. It will ask you to "Refresh" your project.
- You may try Cleaning and Rebuilding your project.
- Go to File->Invalidate Caches/Restart... and then click Invalidate and Restart.
- Basically, reloading your code should fix this problem. If you can find another way to refresh your project and the above did not work, try that way as well.
- 进入你的 gradle 文件,删除一些东西,然后重新输入。它会要求您“刷新”您的项目。
- 您可以尝试清理和重建您的项目。
- 转到 File->Invalidate Caches/Restart...,然后单击 Invalidate and Restart。
- 基本上,重新加载代码应该可以解决这个问题。如果您可以找到另一种刷新项目的方法,但上述方法不起作用,也请尝试这种方法。
回答by Farwa
None of the above solutions worked for me. This does the magic!
以上解决方案都不适合我。这很神奇!
File > Sync Project with Gradle Files
文件 > 将项目与 Gradle 文件同步
回答by voghDev
I'm having this error so often, and I find myself coming to this page again and again. Let me just collect the different answers that worked for me.
我经常遇到这个错误,我发现自己一次又一次地来到这个页面。让我收集对我有用的不同答案。
Solution 1:Combines the ones that @TheAnonymous010 and @Farwa proposed
方案一:结合@TheAnonymous010 和@Farwa 提出的方案
1.- File > Sync project with Gradle Files
1.- 文件 > 使用 Gradle 文件同步项目
2.- Build > Clean Project, Build > Rebuild Project
2.- 构建 > 清理项目,构建 > 重建项目
Solution 2:Recreating Gradle folder
解决方案 2:重新创建Gradle 文件夹
1.- File > Close Project
1.- 文件 > 关闭项目
2.- You will see a small Android Studio window with a list of projects on the left, click on the "X" mark next to your current project (the one you're working on)
2.- 您将在左侧看到一个带有项目列表的小型 Android Studio 窗口,单击当前项目(您正在处理的项目)旁边的“X”标记
2b.- If you don't see an "X" mark next to the project name, you can right-click and select "Remove from project list"
2b.- 如果您在项目名称旁边没有看到“X”标记,您可以右键单击并选择“从项目列表中删除”
3.- Now choose "Open an existing Android Studio Project" and re-open it from zero. After the "Indexing..." phase, you'll probably get your app module back to work
3.- 现在选择“打开现有的 Android Studio 项目”并从零重新打开它。在“索引...”阶段之后,您可能会让您的应用程序模块恢复工作
Solution 3:File > Invalidate caches and restart > Invalidate and Restart
解决方案 3:文件 > 使缓存无效并重新启动 > 使缓存无效并重新启动
Solution 4:Select a debug
variant, sometimes I had this error because of selecting a release
build variant, which has no signature (taken from here)
解决方案 4:选择一个debug
变体,有时我会因为选择一个release
没有签名的构建变体而出现此错误(取自此处)
回答by Shahbaz Ahmed
Problem is there is confliction of Jre, Go to(File -> Project Structure -> SDK Location), just ticked 'Use embedded JDK'(recommended) checkbox and set JDK location to 'path to the android studio'\Android Studio\jre
问题是 Jre 存在冲突,转到(文件 -> 项目结构 -> SDK 位置),只需勾选“使用嵌入式 JDK”(推荐)复选框并将 JDK 位置设置为“android studio 的路径”\Android Studio\jre
回答by Null Pointer Exception
Its very simple. sometimes when you open your project then this error occur. just write some thing in gradle and remove it then sync it. the error will be gone
它非常简单。有时当您打开项目时会发生此错误。只需在 gradle 中写一些东西并删除它然后同步它。错误将消失
回答by afna aliyar
Steps:
脚步:
Open File in Android Studio and click on invalidate.
Open File and click on "close project".
One window with headline "welcome to Android studio" will open.
Remove the project from the opened window (probably listed on top), by clicking on "X" mark.
Close the window with headline "welcome to Android Studio".
Open Android Studio, and select the option to "Open and existing android Studio project".
在 Android Studio 中打开 File 并单击 invalidate。
打开文件并单击“关闭项目”。
将打开一个标题为“欢迎使用 Android 工作室”的窗口。
通过单击“X”标记从打开的窗口(可能列在顶部)中删除项目。
关闭标题为“欢迎使用 Android Studio”的窗口。
打开Android Studio,选择“打开和现有的android Studio项目”选项。
回答by Rahul Khatri
Shut Down Project. Now, Go to File-> New -> Import Project Select Project
关闭项目。现在,转到文件-> 新建-> 导入项目选择项目
It work for me, hope it will help others.
它对我有用,希望它能帮助别人。