Android Kotlin build failing on task "compileDebugKotlinAfterJava", only in automated build

android
gradle
java

#1

Hi,
I have a problem my project won’t compile successfully as there are some problems with compiling kotlin. This process is working on all my computers and my VPS. Also when I ssh into the build and after it fails, try to run in directly from there, it works with no problem. It only throws this error in the automated build.
The build is failing on this gradle task: ':app:compileDebugKotlinAfterJava'

The output:

> Building 74%FAILURE: 
> Building 74%Build failed with an exception.
> Building 74%
> Building 74%
> Building 74%* What went wrong:
> Building 74%Execution failed for task ':app:compileDebugKotlinAfterJava'.
> Building 74%> 
> Building 74%Compilation error. See log for more details
> Building 74%
> Building 74%* Try:
> Building 74%Run`indent preformatted text by 4 spaces` with 
> Building 74%--stacktrace
> Building 74% option to get the stack trace. Run with 
> Building 74%--debug
> Building 74% option to get more log output.
> Building 74%
> Building 74%BUILD FAILED

The gradle stacktrace

Building 74%org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugKotlinAfterJava'.
> Building 74%	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
> Building 74%	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
> Building 74%	at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
> Building 74%	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
> Building 74%	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
> Building 74%	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
> Building 74%	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
> Building 74%	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
> Building 74%	at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
> Building 74%	at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
> Building 74%	at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
> Building 74%	at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
> Building 74%	at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
> Building 74%	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
> Building 74%	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
> Building 74%	at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
> Building 74%	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
> Building 74%	at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
> Building 74%	at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
> Building 74%	at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
> Building 74%	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
> Building 74%	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
> Building 74%	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
> Building 74%	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
> Building 74%	at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
> Building 74%	at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
> Building 74%	at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
> Building 74%	at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
> Building 74%	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
> Building 74%	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
> Building 74%	at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:47)
> Building 74%	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
> Building 74%	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
> Building 74%	at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:35)
> Building 74%	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
> Building 74%	at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
> Building 74%	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
> Building 74%	at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
> Building 74%	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
> Building 74%	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71)
> Building 74%	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69)
> Building 74%	at org.gradle.util.Swapper.swap(Swapper.java:38)
> Building 74%	at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69)
> Building 74%	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
> Building 74%	at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
> Building 74%	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
> Building 74%	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
> Building 74%	at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:70)
> Building 74%	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
> Building 74%	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
> Building 74%	at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39)
> Building 74%	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
> Building 74%	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:46)
> Building 74%	at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
> Building 74%	at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
> Building 74%Caused by: org.gradle.api.GradleException: Compilation error. See log for more details
> Building 74%	at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.callCompiler(Tasks.kt:93)
> Building 74%	at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.compile(Tasks.kt:66)
> Building 74%	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
> Building 74%	at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
> Building 74%	at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
> Building 74%	at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
> Building 74%	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:579)
> Building 74%	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:562)
> Building 74%	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
> Building 74%	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
> Building 74%	... 54 more

my circle.yml

machine:
    environment:
        GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx3900m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError"'

dependencies:
    override:
        - echo y | android update sdk --no-ui --all --filter build-tools-23.0.1,android-23,extra-google-m2repository,extra-android-m2repository,extra-google-google_play_services,extra-android-support
        - ./gradlew dependencies

test:
  override:
    - ./gradlew clean assemble -PdisablePreDex -i --stacktrace

the command I am running:

 ./gradlew clean assemble -PdisablePreDex -i

I tried many variations of this command, including assembleDebug, assemble only, assembleRelease, etc., all have the same output when the automated test is running. It also shows a bunch of errors like:

public val android.app.Activity.toolbar: android.support.v7.widget.Toolbar! defined in kotlinx.android.synthetic.toolbar

etc. but as I say, no problem on my computer, server or even when I ssh into the build and run exactly the same command.


#2

I can’t really help with your problem, as I haven’t run into this myself. But, I can provide one sidecar of help: if you set the environment variable TERM to “dumb”, the build output won’t contain “Building 74%” over and over again. I know, doesn’t help your problem exactly, but it might make it easier to diagnose issues with less garbage output.

eg:

test:
  override:
    # For build speed, I've overridden this to just run the debug tests.
    - TERM="dumb" ./gradlew testDebugUnitTest

#3

Thanks for your tip, the output is much cleaner now, but the errors I am getting are quite strange because I am unable to reproduce the anywhere else (even when I SSH to the machine and run the same command right there by myself)


#4