AndroidStudio build failed
使用安卓AndroidStudio开发应用的时候,经常会出现编译失败的情况,有的时候,AS会告诉我们是哪里出了问题,但是有的时候只会提示一段类似这样的话:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':chat_lib:compileDebugKotlin'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
...
对于这样的描述,我们也只是一头雾水,有没有可能知道更加清除的错误信息呢?答案是有的,而且就在上面的输出日志里面。上面错误信息的第一句话写的是org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':chat_lib:compileDebugKotlin'.
,这里已经告诉我们是因为什么出了问题,原来就是执行chat_lib:compileDebugKotlin
的时候报错了。我们打开AS的终端,输入:
gradlew chat_lib:compileDebugKotlin
运行这个TASK,就可以看到详情的错误原因了。