Generate junit test report fails on Jenkins with Android N device

Gradle Version: 2.14.1
Operating System: Jenkins (Win 7 64bit), Testdevice (Nexus 9 OS 7.0)
Is this a regression? If yes, which version of Gradle do you know it last worked for?

Logoutput on Jenkins:
07:13:29.613 [DEBUG] [org.gradle.api.Task] DeviceConnector ‘Nexus 7 - 6.0.1’: uninstalling mypackage.debug.test
07:13:30.949 [DEBUG] [org.gradle.api.Task] DeviceConnector ‘Nexus 7 - 6.0.1’: uninstalling mypackage.debug
07:13:32.613 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':MyApp:connectedFlavor1DebugAndroidTest’
07:13:32.613 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :MyApp:connectedFlavor1DebugAndroidTest FAILED
07:13:32.613 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :MyApp:connectedFlavor1DebugAndroidTest (Thread[main,5,main]) completed. Took 1 mins 2.702 secs.
07:13:32.613 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 2 mins 32.052 secs, idle: 0.022 secs
07:13:32.618 [ERROR] [org.gradle.BuildExceptionReporter]
07:13:32.619 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
07:13:32.619 [ERROR] [org.gradle.BuildExceptionReporter]
07:13:32.620 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
07:13:32.620 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ‘:MyApp:connectedFlavor1DebugAndroidTest’.
07:13:32.620 [ERROR] [org.gradle.BuildExceptionReporter] > Could not generate test report to ‘D:\jenkins\workspace\JUnit_App_Android_HEAD\APP\MyApp\build\reports\androidTests\connected\flavors\FLAVOR1’.
07:13:32.620 [ERROR] [org.gradle.BuildExceptionReporter]
07:13:32.620 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
07:13:32.621 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:MyApp:connectedFlavor1DebugAndroidTest’.
07:13:32.621 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
07:13:32.621 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
07:13:32.621 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
07:13:32.622 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
07:13:32.622 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
07:13:32.622 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
07:13:32.622 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
07:13:32.622 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
07:13:32.622 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
07:13:32.622 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
07:13:32.622 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
07:13:32.622 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
07:13:32.622 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
07:13:32.622 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
07:13:32.623 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
07:13:32.623 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
07:13:32.623 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
07:13:32.623 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
07:13:32.623 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
07:13:32.623 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
07:13:32.623 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
07:13:32.623 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
07:13:32.623 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:153)
07:13:32.623 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.Factories$1.create(Factories.java:22)
07:13:32.623 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
07:13:32.624 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)
07:13:32.624 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:150)
07:13:32.624 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
07:13:32.624 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98)
07:13:32.624 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92)
07:13:32.624 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
07:13:32.624 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
07:13:32.624 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92)
07:13:32.624 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)
07:13:32.624 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:99)
07:13:32.624 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
07:13:32.624 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
07:13:32.625 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:48)
07:13:32.625 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
07:13:32.625 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81)
07:13:32.625 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46)
07:13:32.625 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
07:13:32.625 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
07:13:32.625 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
07:13:32.625 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)
07:13:32.625 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:239)
07:13:32.625 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:212)
07:13:32.625 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
07:13:32.626 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
07:13:32.626 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
07:13:32.626 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
07:13:32.626 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:205)
07:13:32.626 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
07:13:32.626 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.Main.doAction(Main.java:33)
07:13:32.626 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
07:13:32.626 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:55)
07:13:32.626 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36)
07:13:32.626 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
07:13:32.626 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.api.GradleException: Could not generate test report to ‘D:\jenkins\workspace\JUnit_App_Android_HEAD\APP\MyApp\build\reports\androidTests\connected\flavors\FLAVOR1’.
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TestReport.generateFiles(TestReport.java:159)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TestReport.generateReport(TestReport.java:59)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.tasks.DeviceProviderInstrumentTestTask.runTests(DeviceProviderInstrumentTestTask.java:136)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:228)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:621)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:604)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
07:13:32.627 [ERROR] [org.gradle.BuildExceptionReporter] … 60 more
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.api.UncheckedIOException: Could not write to file ‘D:\jenkins\workspace\JUnit_App_Android_HEAD\APP\MyApp\build\reports\androidTests\connected\flavors\FLAVOR1\mypackage2.ApplicationTest.html’.
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.IoActions$TextFileWriterIoAction.execute(IoActions.java:132)
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.IoActions$TextFileWriterIoAction.execute(IoActions.java:108)
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.IoActions.writeTextFile(IoActions.java:38)
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TextReportRenderer.writeTo(TextReportRenderer.java:37)
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.HtmlReportRenderer$1.writeTo(HtmlReportRenderer.java:56)
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TestReport.generatePage(TestReport.java:166)
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TestReport.generateFiles(TestReport.java:154)
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] … 70 more
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.NullPointerException
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.ClassPageRenderer.renderTests(ClassPageRenderer.java:92)
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.ClassPageRenderer.access$000(ClassPageRenderer.java:34)
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.ClassPageRenderer$1.doExecute(ClassPageRenderer.java:217)
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.ClassPageRenderer$1.doExecute(ClassPageRenderer.java:214)
07:13:32.628 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.ErroringAction.execute(ErroringAction.java:35)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.PageRenderer$1.render(PageRenderer.java:48)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.PageRenderer$1.render(PageRenderer.java:45)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TabsRenderer.render(TabsRenderer.java:54)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.PageRenderer.renderTabs(PageRenderer.java:54)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.PageRenderer$6.render(PageRenderer.java:244)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.PageRenderer$6.render(PageRenderer.java:238)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TabbedPageRenderer.render(TabbedPageRenderer.java:59)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TabbedPageRenderer.render(TabbedPageRenderer.java:26)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.HtmlReportRenderer$TextReportRendererImpl.writeTo(HtmlReportRenderer.java:105)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.HtmlReportRenderer$1.writeTo(HtmlReportRenderer.java:51)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TextReportRenderer$1.doExecute(TextReportRenderer.java:40)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TextReportRenderer$1.doExecute(TextReportRenderer.java:37)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.ErroringAction.execute(ErroringAction.java:35)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.IoActions$TextFileWriterIoAction.execute(IoActions.java:127)
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter] … 76 more
07:13:32.629 [ERROR] [org.gradle.BuildExceptionReporter]
07:13:32.630 [LIFECYCLE] [org.gradle.BuildResultLogger]
07:13:32.630 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
07:13:32.630 [LIFECYCLE] [org.gradle.BuildResultLogger]
07:13:32.630 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 3 mins 49.066 secs
07:13:32.638 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache taskArtifacts.bin (D:\jenkins\workspace\JUnit_App_Android_HEAD\APP.gradle\2.14.1\taskArtifacts\taskArtifacts.bin)
07:13:32.638 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileHashes.bin (D:\jenkins\workspace\JUnit_App_Android_HEAD\APP.gradle\2.14.1\taskArtifacts\fileHashes.bin)
07:13:32.639 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileSnapshots.bin (D:\jenkins\workspace\JUnit_App_Android_HEAD\APP.gradle\2.14.1\taskArtifacts\fileSnapshots.bin)
07:13:32.639 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileSnapshotsToTreeSnapshotsIndex.bin (D:\jenkins\workspace\JUnit_App_Android_HEAD\APP.gradle\2.14.1\taskArtifacts\fileSnapshotsToTreeSnapshotsIndex.bin)
07:13:32.639 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on task history cache (D:\jenkins\workspace\JUnit_App_Android_HEAD\APP.gradle\2.14.1\taskArtifacts).
07:13:32.639 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache classAnalysis.bin (D:\jenkins\workspace\JUnit_App_Android_HEAD\caches\2.14.1\classAnalysis\classAnalysis.bin)
07:13:32.639 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on class analysis cache (D:\jenkins\workspace\JUnit_App_Android_HEAD\caches\2.14.1\classAnalysis).
07:13:32.640 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache jarSnapshots.bin (D:\jenkins\workspace\JUnit_App_Android_HEAD\caches\2.14.1\jarSnapshots\jarSnapshots.bin)
07:13:32.640 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on jar snapshots cache (D:\jenkins\workspace\JUnit_App_Android_HEAD\caches\2.14.1\jarSnapshots).
07:13:32.641 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory] Resolution result cache closed. Cache reads: 0, disk reads: 0 (avg: 0.0 secs, total: 0.0 secs)
07:13:32.641 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory] Resolution result cache closed. Cache reads: 0, disk reads: 28 (avg: 0.0 secs, total: 0.023 secs)
07:13:32.642 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.ResolutionResultsStoreFactory] Deleted 2 resolution results binary files in 0.002 secs
07:13:32.642 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedRepositoryFactory] In-memory dependency metadata cache closed. Repos cached: 272, cache instances: 7, modules served from cache: 2143, artifacts: 326
07:13:32.642 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache Generated Gradle JARs cache (D:\jenkins\workspace\JUnit_App_Android_HEAD\caches\2.14.1\generated-gradle-jars) was closed 0 times.
07:13:32.642 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-metadata.bin (D:\jenkins\workspace\JUnit_App_Android_HEAD\caches\modules-2\metadata-2.16\module-metadata.bin)
07:13:32.642 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-versions.bin (D:\jenkins\workspace\JUnit_App_Android_HEAD\caches\modules-2\metadata-2.16\module-versions.bin)
07:13:32.642 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache artifact-at-repository.bin (D:\jenkins\workspace\JUnit_App_Android_HEAD\caches\modules-2\metadata-2.16\artifact-at-repository.bin)
07:13:32.642 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on artifact cache (D:\jenkins\workspace\JUnit_App_Android_HEAD\caches\modules-2).
07:13:32.643 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache Plugin Resolution Cache (D:\jenkins\workspace\JUnit_App_Android_HEAD\caches\2.14.1\plugin-resolution) was closed 0 times.
07:13:32.643 [DEBUG] [org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonManager] Stopping 0 compiler daemon(s).
07:13:32.643 [INFO] [org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonManager] Stopped 0 compiler daemon(s).
Build step ‘Invoke Gradle script’ changed build result to FAILURE
Build step ‘Invoke Gradle script’ marked build as failure
Zeichne Testergebnisse auf.
Finished: FAILURE

Hi,

thanks for your report. Could you give a little bit more context? Also consider sharing a Build Scan.

We have a project with the following structure:

-MyProject
    -MyModule
        -MyFlavor1
        -MyFlavor2
        -MyFlavor3
        -MyFlavor4
        -MyFlavor5
        -main
        -androidTest
            -FlavorX
                ApplicationTest.java

When you create a new flavor in AndroidStudio, then per default AS generates an ApplicationTest.java in the androidTest package for each flavor without any testcases.
In our case, these class exists just for one flavor. Then if the connectedFlavorXDebugAndroidTest task gets executed, it ends up in the following Exception:

08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.api.UncheckedIOException: Could not write to file ‘D:\Workspace\MYPROJECT\MyModule\build\reports\androidTests\connected\flavors\MYFLAVOR\my.package.flavor2.ApplicationTest.html’.
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.IoActions$TextFileWriterIoAction.execute(IoActions.java:132)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.IoActions$TextFileWriterIoAction.execute(IoActions.java:108)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.IoActions.writeTextFile(IoActions.java:38)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TextReportRenderer.writeTo(TextReportRenderer.java:37)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.HtmlReportRenderer$1.writeTo(HtmlReportRenderer.java:56)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TestReport.generatePage(TestReport.java:166)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TestReport.generateFiles(TestReport.java:154)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] … 80 more
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.NullPointerException
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.ClassPageRenderer.renderTests(ClassPageRenderer.java:92)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.ClassPageRenderer.access$000(ClassPageRenderer.java:34)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.ClassPageRenderer$1.doExecute(ClassPageRenderer.java:217)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.ClassPageRenderer$1.doExecute(ClassPageRenderer.java:214)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.ErroringAction.execute(ErroringAction.java:35)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.PageRenderer$1.render(PageRenderer.java:48)
08:24:55.279 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.PageRenderer$1.render(PageRenderer.java:45)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TabsRenderer.render(TabsRenderer.java:54)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.PageRenderer.renderTabs(PageRenderer.java:54)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.PageRenderer$6.render(PageRenderer.java:244)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.PageRenderer$6.render(PageRenderer.java:238)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TabbedPageRenderer.render(TabbedPageRenderer.java:59)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TabbedPageRenderer.render(TabbedPageRenderer.java:26)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.HtmlReportRenderer$TextReportRendererImpl.writeTo(HtmlReportRenderer.java:105)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.HtmlReportRenderer$1.writeTo(HtmlReportRenderer.java:51)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TextReportRenderer$1.doExecute(TextReportRenderer.java:40)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.test.report.TextReportRenderer$1.doExecute(TextReportRenderer.java:37)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.ErroringAction.execute(ErroringAction.java:35)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.IoActions$TextFileWriterIoAction.execute(IoActions.java:127)
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter] … 86 more
08:24:55.280 [ERROR] [org.gradle.BuildExceptionReporter]
08:24:55.280 [LIFECYCLE] [org.gradle.BuildResultLogger]
08:24:55.280 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED

After i delete the “FlavorX” folder with the ApplicationTest.java the build is successful.

Could you try with Gradle 3.0? The Android plugin with version 2.2.0-beta2 should work with Gradle 3.0. Also, a self contained example would be very helpful.

We had the same error. Turned out it’s not Gradle but calling deprecated API in ApplicationTest.java
Just delete the ApplicationTestCase and the error should be gone