我从昨天起就有一个非常奇怪的问题。如果我在Android Studio中使用运行按钮,则有时Android Studio无法完成Gradle执行。
在Android Studio的gradle控制台中,我首先收到消息:
:app:compileDevelopmentDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
其次是:
:app:dexDevelopmentDebug
AGPBI: {"kind":"simple","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]}
AGPBI: {"kind":"simple","text":"(org.apache.commons.httpclient.HttpMethodBase$1) that doesn\u0027t come with an","sources":[{}]}
AGPBI: {"kind":"simple","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]}
AGPBI: {"kind":"simple","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]}
AGPBI: {"kind":"simple","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]}
AGPBI: {"kind":"simple","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]}
AGPBI: {"kind":"simple","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]}
AGPBI: {"kind":"simple","text":"indicate that it is *not* an inner class.","sources":[{}]}
然后gradle控制台说BUILD SUCCESSFUL但是Android Studio给了我错误信息" Gradle Running无法完成Gradle执行"但没有原因(它是空的,见图)。
运行按钮不再可点击,我必须单击"将项目与gradle文件同步"。之后我可以运行应用程序几次(在设备上),而不会在上面发布任何错误消息。几次后,相同的错误消息再次出现。
答案 0 :(得分:1)
随着最新Android Studio版本1.3(测试版)的更新,问题已经消失。控制台显示相同的警告,但Android Studio不会失败。
答案 1 :(得分:1)
在我的情况下,通过在上一个目录中构建Gradle来解决问题。
最初,我将项目放在不同的目录中,当我将其移动到另一个目录时,它显示上述错误,但在将其移回上一个目录错误后排序。
希望它能提供帮助。
答案 2 :(得分:0)
有时,gradle会出现此错误,但您可以毫无问题地运行您的应用。否则,如果问题出在插件或任何其他样板代码上,则gradle可能不会显示错误。
在这种情况下,您可以看到打开终端选项卡并执行此命令的问题:
gradlew assembleDebug --stacktrace
在此之后,您可以看到错误日志(如果存在)。