Java Android Studio:无法完成gradle执行,原因为空
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27407855/
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
Android Studio: failed to complete gradle execution, cause is empty
提问by user3142817
When I try to run an Android emulator, I get the following error screen. The same occurs when I export the apk. When I go to the directory where the apk will be saved, the apk file is not there.
当我尝试运行 Android 模拟器时,出现以下错误屏幕。当我导出 apk 时也会发生同样的情况。当我转到将保存 apk 的目录时, apk 文件不在那里。
Thank you,
christophe
谢谢你,
克里斯托夫
采纳答案by A J
I had the same issue, this problem will be fixed by doing the below step.
我有同样的问题,这个问题将通过执行以下步骤来解决。
Go to
去
File->Setting->Gradle->Gradle Vm Option
文件->设置->Gradle->Gradle Vm 选项
For Android Studio 1.2
对于 Android Studio 1.2
File->Setting->Build, Deployment &Execution->Build Tools->Gradle->Gradle Vm Option
File->Setting->Build, Deployment &Execution->Build Tools->Gradle->Gradle Vm Option
, Now put this value -Xmx256m
in the box, and hit the Apply button.
, 现在将此值-Xmx256m
放入框中,然后点击应用按钮。
回答by SiavA
I had this issue too. It caused by mistake in dimens.xml (git helps me found it).
我也有这个问题。它是由 dimens.xml 中的错误引起的(git 帮我找到了它)。
I used
我用了
<dimen name="map_search_view_top_margin">100</dimen>
<dimen name="map_search_view_top_margin">100</dimen>
instead
反而
<dimen name="map_search_view_top_margin">100dp</dimen>
<dimen name="map_search_view_top_margin">100dp</dimen>
Hope it helps.
希望能帮助到你。
回答by sv_jan5
This dialog box with empty cause also comes when there is some error in your resource(res) directory. Check for any error in layout files etc.
当您的资源(res)目录中存在一些错误时,也会出现此原因为空的对话框。检查布局文件等中的任何错误。
回答by Mr. Kro
In my case the root of the problem was, I deleted some resources that some xml files were refering to, and in that case neither of "Clear Project" "Rebuild Project" "Gradle VM Option" or "deleting .gradle folder" helped at all.
在我的情况下,问题的根源是,我删除了一些 xml 文件所引用的一些资源,在这种情况下,“清除项目”“重建项目”“Gradle VM 选项”或“删除 .gradle 文件夹”都没有帮助全部。
What more to say is, none of the mentioned xml files were in use, and no error was displayed anywhere. I only detected the problem when (in desperate) sync'ed Gradle, and then opened the Gradle console and scrolled up and read the red error lines.
更要说的是,提到的xml文件都没有被使用,并且任何地方都没有显示错误。我只在(绝望地)同步 Gradle时才检测到问题,然后打开 Gradle 控制台并向上滚动并阅读红色错误行。
回答by Mingsheng
- Click "Gradle Console" for the log from Gradle.
- Debug from the error messages
- Mac: In Android Studio, go to:
- "Preference"
- "Build, Execution, Deployment"
- "Compiler"
- Add "--stacktrace" to "Command-line Options"
- Mac: In Android Studio, go to:
- 单击“Gradle Console”以获取来自 Gradle 的日志。
- 从错误消息中调试
- Mac:在 Android Studio 中,转到:
- “偏爱”
- “构建、执行、部署”
- “编译器”
- 将“--stacktrace”添加到“命令行选项”
- Mac:在 Android Studio 中,转到:
Note the error will usually be listed as the first line (improperly formatted for Android Studio Gradle console such as:
请注意,错误通常会列在第一行(Android Studio Gradle 控制台格式不正确,例如:
AGPBI: {"kind":"error","text":"Float types not allowed (at \u0027icon_alpha_active\u0027 with value \u00270.75\u0027).","sources":[{"file":"/Users/mingsheng/path/to/my/errenous/integers.xml","position":{"startLine":5,"startColumn":38,"startOffset":272,"endColumn":42,"endOffset":276}}],"original":""}
AGPBI: {"kind":"error","text":"不允许浮点类型(在 \u0027icon_alpha_active\u0027 处,值为 \u00270.75\u0027)。","sources":[{"file":"/ Users/mingsheng/path/to/my/errenous/integers.xml","position":{"startLine":5,"startColumn":38,"startOffset":272,"endColumn":42,"endOffset": 276}}],“原始”:“”}
Where "text" = error message, "sources: file" = errenous filepath/name
其中“文本”= 错误消息,“来源:文件”= 错误的文件路径/名称
In this example, I have entered a Float value in the integers file.
在这个例子中,我在整数文件中输入了一个浮点值。
回答by Amit Tumkur
Honestly speaking, to me none of the above solutions worked and i almost fought over this for 3 days. Finally ultimate solution was to backup my project, uninstall studio and its trace files completely, clear files from temp, %temp% and prefetch folders and then reinstall all over again and finally it worked.
老实说,对我来说,上述解决方案都没有奏效,我几乎为此奋斗了 3 天。最后的最终解决方案是备份我的项目,完全卸载 Studio 及其跟踪文件,从 temp、%temp% 和 prefetch 文件夹中清除文件,然后重新安装,最后它起作用了。
Pls discard my above answer which i taught was one of the solutions. I faced this problem repeatedly because 1 of my teammate forgot to include git.ignore file while pushing code to bitbucket and everytime i used to pull that code and then gradle used to pop the above problem. And after figuring out that, i have added proper git.ignore file and now there's no any problem on any1's pc :)
请放弃我上面的答案,我教的是解决方案之一。我反复遇到这个问题,因为我的一个队友在将代码推送到 bitbucket 时忘记包含 git.ignore 文件,并且每次我曾经拉过该代码,然后 gradle 用来弹出上述问题。弄清楚之后,我添加了正确的 git.ignore 文件,现在 any1 的 pc 上没有任何问题:)
回答by Rodrigo Venancio
None of the solutions worked for me. So I found this solution here:
没有一个解决方案对我有用。所以我在这里找到了这个解决方案:
My Android Studio was using JDK 1.8, so I switched back to JDK 1.7 and now it is working!
我的 Android Studio 使用的是 JDK 1.8,所以我切换回 JDK 1.7,现在它可以工作了!
Go to
去
File > Project Structure > SDK Location
文件 > 项目结构 > SDK 位置
I had JDK Locationset as jdk1.8.0_05. I just changed it to jdk1.7.0_79 and everything works fine now.
我将JDK 位置设置为 jdk1.8.0_05。我刚刚将其更改为 jdk1.7.0_79,现在一切正常。
回答by Zhivko Dunovski
I am often getting that error when I have a typo in my xml. Open the gradle console and scroll up to the first red lines that appear. It will tell you the exact problem.
当我的 xml 中有拼写错误时,我经常收到该错误。打开 gradle 控制台并向上滚动到出现的第一条红线。它会告诉你确切的问题。
回答by Victor Petrovski
This is a mistake somewhere in your xml files. Check
这是您的 xml 文件中某处的错误。查看
values.xml
colors.xml
strings.xml
dimens.xml
Something wrong with opening closing bracket or something you missed in these files.
打开右括号或您在这些文件中遗漏的内容有问题。
回答by Simon Pan
I have this problem, too. I used Gradle v.1.3.1 but Android Studio version is v1.2.2. Just update Android Studio to v.1.3.2 solved my problem.
我也有这个问题。我使用 Gradle v.1.3.1 但 Android Studio 版本是 v1.2.2。只需将 Android Studio 更新到 v.1.3.2 即可解决我的问题。