热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

AndroidStudio和Gradle构建错误-AndroidStudioandGradlebuilderror

Ivebeenusingthenewpreviewofandroidstudioandreallylikeit.Butrecentlymyprojectwont

I've been using the new preview of android studio and really like it. But recently my project won't build. I get the following error:

我一直在使用android studio的新预览版,并且非常喜欢它。但最近我的项目无法构建。我得到了以下错误:

Gradle: 
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':TestProj:compileDebug'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.

Question is how do I enable the stack trace so I can get to the root of the error. As it is I really have no idea what's causing this.

问题是如何启用堆栈跟踪,以便找到错误的根源。事实上,我真的不知道是什么引起的。

8 个解决方案

#1


43  

If you are using the Gradle Wrapper (the recommended option in Android Studio), you enable stacktrace by running gradlew compileDebug --stacktrace from the command line in the root folder of your project (where the gradlew file is).

如果您正在使用Gradle包装器(Android Studio推荐的选项),您可以通过运行gradlew compileDebug—stacktrace从项目根文件夹中的命令行(gradlew文件在其中)来启用stacktrace。

If you are not using the gradle wrapper, you use gradle compileDebug --stacktrace instead (presumably).

如果您不使用gradle包装,那么您将使用gradle compileDebug—stacktrace(大概)。

You don't really need to run with --stacktrace though, running gradlew compileDebug by itself, from the command line, should tell you where the error is.

您不需要使用——stacktrace来运行,通过命令行自己运行gradlew compileDebug,应该会告诉您错误在哪里。

I based this information on this comment:

我根据这一评论提供的信息:

Android Studio new project can not run, throwing error

Android Studio新项目无法运行,抛出错误

#2


5  

Similar to @joe_deniable 's answer the thing I found with my own projects was that gradle would output that kind of error when there was a misconfiguration of my system.

类似于@joe_deniable的回答,我在我自己的项目中发现,当我的系统出现错误时,gradle会输出这种错误。

I discovered that by running gradlew installDebug or similar command from the terminal I got better output as to what the real problem was.

我发现通过在终端上运行gradlew installDebug或类似的命令,我得到了更好的输出,以了解真正的问题是什么。

e.g. initially it turns out my JAVA_HOME was not setup correctly. Then I discovered it encountered errors because I didn't have a package space setup correctly. Etc.

例如,最初发现我的JAVA_HOME没有正确设置。然后我发现它遇到了错误,因为我没有正确地设置包空间。等。

#3


2  

The only solution I've found is to first create the project in Android Studio, then close the project, then import the project. I searched all over and could not find the root cause and all other solutions people posted didn't work.

我发现的唯一解决方案是首先在Android Studio中创建项目,然后关闭项目,然后导入项目。我找遍了所有的地方,都找不到根本原因,所有其他人发布的解决方案都不管用。

#4


0  

OK seems like a caching issue of some sort. There was indeed an error in code with the R.id.some_id not being found but the editor was not picking it up displaying that there were no errors.

OK看起来像是某种缓存问题。在使用R.id的代码中确实有一个错误。没有找到some_id,但是编辑器没有接收到它,显示没有错误。

#5


0  

I installed Android Studio on an old WinXP with only for me option. After install I did the new project wizard and when opening the new project a got some Gradle error with some failed path to my instalation dir. c:/Document"#¤!"#¤ and settins/...

我在一个旧的WinXP上安装了Android Studio,只有for me选项。安装后,我做了新项目向导,当打开新项目a时,我的instalation dir路径有一些错误。c:/文档”#¤!“#¤和设定/…

The I uninstalled and did a new install with option for all users (C:/Programs/..) then I opend the previous created project with no errors.

我卸载并为所有用户安装了一个新的选项(C:/ program /..),然后我选择了之前创建的没有错误的项目。

So it might be a path problem. (Just spent 10 sec debugging, so I might be wrong but it solved my gradle error)

这可能是路径问题。(只是花了10秒调试,所以我可能错了,但它解决了我的等级错误)

#6


0  

I found this post helpful:

我发现这个帖子很有用:

"It can happen when res folder contains unexpected folder names. In my case after merge mistakes I had a folder src/main/res/res. And it caused problems."

当res文件夹包含意外的文件夹名称时,可能会发生这种情况。在合并错误之后,我有一个文件夹src/main/res/res。和它造成的问题。”

from: "https://groups.google.com/forum/#!msg/adt-dev/0pEUKhEBMIA/ZxO5FNRjF8QJ"

来自:“https://groups.google.com/forum/ !味精/ adt-dev / 0 peukhebmia / ZxO5FNRjF8QJ”

#7


0  

I used a local distribution of gradle downloaded from gradle website and used it in android studio.

我使用了一个从gradle网站上下载的gradle的本地发行版,并在android studio中使用。

It fixed the gradle build error.

它修正了渐变构建错误。

#8


0  

Edit the gradle wrapper settings in gradle/wrapper/gradle-wrapper.properties and change gradle-1.6-bin.zip to gradle-2.4-bin.zip.

编辑层次包装设置在层次/包装/层次包装。属性和改变gradle - 1.6 - bin。gradle - 2.4 bin.zip zip。

./gradle/wrapper/gradle-wrapper.properties :

。/它/包装/ gradle-wrapper。属性:

#Wed Apr 10 15:27:10 PDT 2013
distributiOnBase=GRADLE_USER_HOME
distributiOnPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributiOnUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip

It should compile without any error now.

它现在应该编译,没有任何错误。

Note: update version numbers with the most recent ones

注意:用最新的版本号更新版本号


推荐阅读
  • Nginx使用AWStats日志分析的步骤及注意事项
    本文介绍了在Centos7操作系统上使用Nginx和AWStats进行日志分析的步骤和注意事项。通过AWStats可以统计网站的访问量、IP地址、操作系统、浏览器等信息,并提供精确到每月、每日、每小时的数据。在部署AWStats之前需要确认服务器上已经安装了Perl环境,并进行DNS解析。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • baresip android编译、运行教程1语音通话
    本文介绍了如何在安卓平台上编译和运行baresip android,包括下载相关的sdk和ndk,修改ndk路径和输出目录,以及创建一个c++的安卓工程并将目录考到cpp下。详细步骤可参考给出的链接和文档。 ... [详细]
  • 本文介绍了三种方法来实现在Win7系统中显示桌面的快捷方式,包括使用任务栏快速启动栏、运行命令和自己创建快捷方式的方法。具体操作步骤详细说明,并提供了保存图标的路径,方便以后使用。 ... [详细]
  • [大整数乘法] java代码实现
    本文介绍了使用java代码实现大整数乘法的过程,同时也涉及到大整数加法和大整数减法的计算方法。通过分治算法来提高计算效率,并对算法的时间复杂度进行了研究。详细代码实现请参考文章链接。 ... [详细]
  • 本文介绍了如何使用C#制作Java+Mysql+Tomcat环境安装程序,实现一键式安装。通过将JDK、Mysql、Tomcat三者制作成一个安装包,解决了客户在安装软件时的复杂配置和繁琐问题,便于管理软件版本和系统集成。具体步骤包括配置JDK环境变量和安装Mysql服务,其中使用了MySQL Server 5.5社区版和my.ini文件。安装方法为通过命令行将目录转到mysql的bin目录下,执行mysqld --install MySQL5命令。 ... [详细]
  • 本文介绍了在CentOS上安装Python2.7.2的详细步骤,包括下载、解压、编译和安装等操作。同时提供了一些注意事项,以及测试安装是否成功的方法。 ... [详细]
  • 本文由编程笔记#小编为大家整理,主要介绍了logistic回归(线性和非线性)相关的知识,包括线性logistic回归的代码和数据集的分布情况。希望对你有一定的参考价值。 ... [详细]
  • Windows下配置PHP5.6的方法及注意事项
    本文介绍了在Windows系统下配置PHP5.6的步骤及注意事项,包括下载PHP5.6、解压并配置IIS、添加模块映射、测试等。同时提供了一些常见问题的解决方法,如下载缺失的msvcr110.dll文件等。通过本文的指导,读者可以轻松地在Windows系统下配置PHP5.6,并解决一些常见的配置问题。 ... [详细]
  • Linux磁盘的分区、格式化的观察和操作步骤
    本文介绍了如何观察Linux磁盘的分区状态,使用lsblk命令列出系统上的所有磁盘列表,并解释了列表中各个字段的含义。同时,还介绍了使用parted命令列出磁盘的分区表类型和分区信息的方法。在进行磁盘分区操作时,根据分区表类型选择使用fdisk或gdisk命令,并提供了具体的分区步骤。通过本文,读者可以了解到Linux磁盘分区和格式化的基本知识和操作步骤。 ... [详细]
  • 本文介绍了一个在线急等问题解决方法,即如何统计数据库中某个字段下的所有数据,并将结果显示在文本框里。作者提到了自己是一个菜鸟,希望能够得到帮助。作者使用的是ACCESS数据库,并且给出了一个例子,希望得到的结果是560。作者还提到自己已经尝试了使用"select sum(字段2) from 表名"的语句,得到的结果是650,但不知道如何得到560。希望能够得到解决方案。 ... [详细]
  • 本文介绍了在mac环境下使用nginx配置nodejs代理服务器的步骤,包括安装nginx、创建目录和文件、配置代理的域名和日志记录等。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
  • CentOS 6.5安装VMware Tools及共享文件夹显示问题解决方法
    本文介绍了在CentOS 6.5上安装VMware Tools及解决共享文件夹显示问题的方法。包括清空CD/DVD使用的ISO镜像文件、创建挂载目录、改变光驱设备的读写权限等步骤。最后给出了拷贝解压VMware Tools的操作。 ... [详细]
author-avatar
射手座的双子55
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有