问题
I am running a coverage task on Android app. I have added the necessary command testCoverageEnabled = true
in build.gradle file. I can see the task createMockDebugAndroidTestCoverageReport in ./gradlew task list. I executed the tasks createMockDebugAndroidTestCoverageReport and got the following error on the console:
* What went wrong:
Execution failed for task ':myAppApplication:createMockDebugAndroidTestCoverageReport'.
> java.io.IOException: No coverage data to process in directory '/Users/aaa.bbb/Documents/myApp-android/myAppApplication/build/outputs/code-coverage/connected/flavors/MOCK'
When I checked this path, its empty.
The debug logs snippet is:
23:42:33.589 [QUIET] [system.out] 11:42:33 I/XmlResultReporter: XML test result file generated at /Users/aaa.bbb/Documents/myApp-android/myAppApplication/build/outputs/androidTest-results/connected/flavors/MOCK/TEST-Nexus_5X_API_27_Automation-2(AVD) - 8.1.0-myAppApplication-MOCK.xml. Total tests 15, passed 15,
23:42:33.589 [QUIET] [system.out] 11:42:33 V/ddms: execute 'CLASSPATH=$(pm path android.support.test.services) app_process / android.support.test.services.shellexecutor.ShellMain am instrument -r -w -e targetInstrumentation com.chn.myApp.test/android.support.test.runner.AndroidJUnitRunner -e coverageFilePath /data/data/com.chn.myApp/coverage_data/ -e coverage true android.support.test.orchestrator/android.support.test.orchestrator.AndroidTestOrchestrator' on 'emulator-5556' : EOF hit. Read: -1
23:42:33.590 [QUIET] [system.out] 11:42:33 V/ddms: execute: returning
23:42:33.590 [INFO] [org.gradle.api.Task] DeviceConnector 'Nexus_5X_API_27_Automation-2(AVD) - 8.1.0': fetching coverage dir from /data/data/com.chn.myApp/coverage_data/
23:42:33.590 [QUIET] [system.out] 11:42:33 V/ddms: execute: running echo 'for i in $(run-as com.chn.myApp ls /data/data/com.chn.myApp/coverage_data/); do run-as com.chn.myApp cat /data/data/com.chn.myApp/coverage_data/$i > /data/local/tmp/com.chn.myApp-coverage_data/$i; done' > /data/local/tmp/com.chn.myApp-coverage_data/copyFromUser.sh
23:42:33.630 [QUIET] [system.out] 11:42:33 V/ddms: execute 'echo 'for i in $(run-as com.chn.myApp ls /data/data/com.chn.myApp/coverage_data/); do run-as com.chn.myApp cat /data/data/com.chn.myApp/coverage_data/$i > /data/local/tmp/com.chn.myApp-coverage_data/$i; done' > /data/local/tmp/com.chn.myApp-coverage_data/copyFromUser.sh' on 'emulator-5556' : EOF hit. Read: -1
23:42:33.630 [QUIET] [system.out] 11:42:33 V/ddms: execute: returning
23:42:33.631 [QUIET] [system.out] 11:42:33 V/ddms: execute: running sh /data/local/tmp/com.chn.myApp-coverage_data/copyFromUser.sh
23:42:33.668 [QUIET] [system.out] 11:42:33 V/ddms: execute 'sh /data/local/tmp/com.chn.myApp-coverage_data/copyFromUser.sh' on 'emulator-5556' : EOF hit. Read: -1
23:42:33.668 [QUIET] [system.out] 11:42:33 V/ddms: execute: returning
23:42:33.669 [QUIET] [system.out] 11:42:33 V/ddms: execute: running ls /data/local/tmp/com.chn.myApp-coverage_data > /data/local/tmp/com.chn.myApp-coverage_data/paths.txt
23:42:33.711 [QUIET] [system.out] 11:42:33 V/ddms: execute 'ls /data/local/tmp/com.chn.myApp-coverage_data > /data/local/tmp/com.chn.myApp-coverage_data/paths.txt' on 'emulator-5556' : EOF hit. Read: -1
23:42:33.711 [QUIET] [system.out] 11:42:33 V/ddms: execute: returning
23:42:33.711 [QUIET] [system.out] 11:42:33 D/paths.txt: Downloading paths.txt from device 'emulator-5556'
23:42:33.723 [QUIET] [system.out] 11:42:33 D/Device: Downloading file from device 'emulator-5556'
23:42:33.735 [QUIET] [system.out] 11:42:33 V/ddms: execute: running rm -r /data/local/tmp/com.chn.myApp-coverage_data
23:42:33.776 [QUIET] [system.out] 11:42:33 V/ddms: execute 'rm -r /data/local/tmp/com.chn.myApp-coverage_data' on 'emulator-5556' : EOF hit. Read: -1
23:42:33.776 [QUIET] [system.out] 11:42:33 V/ddms: execute: returning
23:42:33.778 [INFO] [org.gradle.api.Task] DeviceConnector 'Nexus_5X_API_27_Automation-2(AVD) - 8.1.0': uninstalling com.chn.myApp.test
23:42:33.778 [QUIET] [system.out] 11:42:33 V/ddms: execute: running pm uninstall com.chn.myApp.test
23:42:34.133 [QUIET] [system.out] 11:42:34 V/ddms: execute 'pm uninstall com.chn.myApp.test' on 'emulator-5556' : EOF hit. Read: -1
23:42:34.133 [QUIET] [system.out] 11:42:34 V/ddms: execute: returning
23:42:34.133 [INFO] [org.gradle.api.Task] DeviceConnector 'Nexus_5X_API_27_Automation-2(AVD) - 8.1.0': uninstalling com.chn.myApp
23:42:34.133 [QUIET] [system.out] 11:42:34 V/ddms: execute: running pm uninstall com.chn.myApp
23:42:34.518 [QUIET] [system.out] 11:42:34 V/ddms: execute 'pm uninstall com.chn.myApp' on 'emulator-5556' : EOF hit. Read: -1
23:42:34.518 [QUIET] [system.out] 11:42:34 V/ddms: execute: returning
23:42:34.548 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Execute runTests for :myAppApplication:connectedMockDebugAndroidTest'
23:42:34.548 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Execute runTests for :myAppApplication:connectedMockDebugAndroidTest' completed
23:42:34.548 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Snapshotting property coverageDir (OUTPUT) for task ':myAppApplication:connectedMockDebugAndroidTest'
23:42:34.549 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
23:42:34.549 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':myAppApplication:connectedMockDebugAndroidTest'
23:42:34.549 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Task :myAppApplication:connectedMockDebugAndroidTest'
23:42:34.550 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Task :myAppApplication:connectedMockDebugAndroidTest' completed
23:42:34.550 [INFO] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] :myAppApplication:connectedMockDebugAndroidTest (Thread[Task worker for ':' Thread 7,5,main]) completed. Took 29.011 secs.
23:42:34.550 [DEBUG] [org.gradle.internal.work.DefaultWorkerLeaseService] Worker lease root.1.23 completed (1 worker(s) in use)
23:42:34.550 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Task worker for ':' Thread 7: released lock on root.1.23
23:42:34.550 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Task worker for ':' Thread 7: released lock on :
23:42:34.551 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Task worker for ':' Thread 7: acquired lock on :
23:42:34.551 [DEBUG] [org.gradle.internal.work.DefaultWorkerLeaseService] Worker lease root.1.23 started (1 worker(s) in use).
23:42:34.551 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Task worker for ':' Thread 7: acquired lock on root.1.23
23:42:34.551 [INFO] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] :myAppApplication:createMockDebugAndroidTestCoverageReport (Thread[Task worker for ':' Thread 7,5,main]) started.
23:42:34.551 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Task :myAppApplication:createMockDebugAndroidTestCoverageReport' started
23:42:34.551 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] :myAppApplication:createMockDebugAndroidTestCoverageReport
23:42:34.551 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':myAppApplication:createMockDebugAndroidTestCoverageReport'
23:42:34.552 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Putting task artifact state for task ':myAppApplication:createMockDebugAndroidTestCoverageReport' into context took 0.0 secs.
23:42:34.552 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ':myAppApplication:createMockDebugAndroidTestCoverageReport' is up-to-date
23:42:34.552 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Implementation for task ':myAppApplication:createMockDebugAndroidTestCoverageReport': com.android.build.gradle.internal.coverage.JacocoReportTask_Decorated@42f81559c641aa92389da2b264b5f09f
23:42:34.552 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Action implementations for task ':myAppApplication:createMockDebugAndroidTestCoverageReport': [com.android.build.gradle.internal.coverage.JacocoReportTask_Decorated@42f81559c641aa92389da2b264b5f09f]
23:42:34.553 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Snapshotting property classFileCollection (ABSOLUTE) for task ':myAppApplication:createMockDebugAndroidTestCoverageReport'
23:42:34.595 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Snapshotting property coverageDirectory (ABSOLUTE) for task ':myAppApplication:createMockDebugAndroidTestCoverageReport'
23:42:34.595 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Snapshotting property coverageFile (ABSOLUTE) for task ':myAppApplication:createMockDebugAndroidTestCoverageReport'
23:42:34.595 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Snapshotting property jacocoClasspath (ABSOLUTE) for task ':myAppApplication:createMockDebugAndroidTestCoverageReport'
23:42:34.595 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Resolve files of :myAppApplication:androidJacocoAnt' started
23:42:34.595 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Resolve files of :myAppApplication:androidJacocoAnt'
23:42:34.595 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Resolve files of :myAppApplication:androidJacocoAnt' completed
23:42:34.596 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Snapshotting property sourceFolders (ABSOLUTE) for task ':myAppApplication:createMockDebugAndroidTestCoverageReport'
23:42:34.620 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Snapshotting property reportDir (OUTPUT) for task ':myAppApplication:createMockDebugAndroidTestCoverageReport'
23:42:34.621 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] No discovered inputs for task ':myAppApplication:createMockDebugAndroidTestCoverageReport'
23:42:34.621 [INFO] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Task ':myAppApplication:createMockDebugAndroidTestCoverageReport' is not up-to-date because:
Task has failed previously.
23:42:34.621 [DEBUG] [org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter] Ensuring directory exists for property reportDir (OUTPUT) at /Users/aaa.bbb/Documents/myApp-android/myAppApplication/build/reports/coverage/mock/debug
23:42:34.621 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':myAppApplication:createMockDebugAndroidTestCoverageReport'.
23:42:34.621 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Execute generateReport for :myAppApplication:createMockDebugAndroidTestCoverageReport' started
23:42:34.622 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Execute generateReport for :myAppApplication:createMockDebugAndroidTestCoverageReport'
23:42:34.622 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Snapshotting property reportDir (OUTPUT) for task ':myAppApplication:createMockDebugAndroidTestCoverageReport'
23:42:34.623 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
23:42:34.623 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':myAppApplication:createMockDebugAndroidTestCoverageReport'
23:42:34.623 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] :myAppApplication:createMockDebugAndroidTestCoverageReport FAILED
23:42:34.623 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Task :myAppApplication:createMockDebugAndroidTestCoverageReport'
23:42:34.623 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Task :myAppApplication:createMockDebugAndroidTestCoverageReport' completed
23:42:34.623 [INFO] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] :myAppApplication:createMockDebugAndroidTestCoverageReport (Thread[Task worker for ':' Thread 7,5,main]) completed. Took 0.072 secs.
23:42:34.623 [DEBUG] [org.gradle.internal.work.DefaultWorkerLeaseService] Worker lease root.1.23 completed (1 worker(s) in use)
23:42:34.623 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Task worker for ':' Thread 7: released lock on root.1.23
23:42:34.624 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Task worker for ':' Thread 7: released lock on :
23:42:34.624 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 7,5,main]] finished, busy: 30.443 secs, idle: 25.235 secs
23:42:34.624 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 5,5,main]] finished, busy: 0.0 secs, idle: 55.678 secs
23:42:34.624 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 2,5,main]] finished, busy: 4.917 secs, idle: 50.762 secs
23:42:34.624 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Daemon worker Thread 7,5,main]] finished, busy: 0.719 secs, idle: 54.959 secs
23:42:34.624 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 3,5,main]] finished, busy: 0.0 secs, idle: 55.679 secs
23:42:34.624 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':',5,main]] finished, busy: 19.484 secs, idle: 36.195 secs
23:42:34.624 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 4,5,main]] finished, busy: 0.0 secs, idle: 55.679 secs
23:42:34.624 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 6,5,main]] finished, busy: 0.0 secs, idle: 55.678 secs
23:42:34.626 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Run tasks'
23:42:34.630 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] 58 actionable tasks: 11 executed, 47 up-to-date
23:42:34.630 [DEBUG] [org.gradle.internal.work.DefaultWorkerLeaseService] Worker lease root.1 completed (0 worker(s) in use)
23:42:34.630 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Daemon worker Thread 7: released lock on root.1
23:42:34.631 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Run build'
23:42:34.633 [DEBUG] [org.gradle.cache.internal.LockOnDemandCrossProcessCacheAccess] Releasing file lock for file content cache (/Users/aaa.bbb/Documents/myApp-android/.gradle/4.6/fileContent)
23:42:34.634 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on file content cache (/Users/aaa.bbb/Documents/myApp-android/.gradle/4.6/fileContent).
23:42:34.636 [DEBUG] [org.gradle.cache.internal.LockOnDemandCrossProcessCacheAccess] Releasing file lock for task history cache (/Users/aaa.bbb/Documents/myApp-android/.gradle/4.6/taskHistory)
23:42:34.636 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache taskHistory.bin (/Users/aaa.bbb/Documents/myApp-android/.gradle/4.6/taskHistory/taskHistory.bin)
23:42:34.637 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on task history cache (/Users/aaa.bbb/Documents/myApp-android/.gradle/4.6/taskHistory).
23:42:34.638 [DEBUG] [org.gradle.cache.internal.LockOnDemandCrossProcessCacheAccess] Releasing file lock for Build Output Cleanup Cache (/Users/aaa.bbb/Documents/myApp-android/.gradle/buildOutputCleanup)
23:42:34.639 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache outputFiles.bin (/Users/aaa.bbb/Documents/myApp-android/.gradle/buildOutputCleanup/outputFiles.bin)
23:42:34.639 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on Build Output Cleanup Cache (/Users/aaa.bbb/Documents/myApp-android/.gradle/buildOutputCleanup).
23:42:34.640 [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)
23:42:34.641 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory] Resolution result cache closed. Cache reads: 0, disk reads: 1 (avg: 0.0 secs, total: 0.0 secs)
23:42:34.644 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.ResolutionResultsStoreFactory] Deleted 8 resolution results binary files in 0.004 secs
23:42:34.645 [DEBUG] [org.gradle.deployment.internal.DefaultDeploymentRegistry] Stopping 0 deployment handles
23:42:34.645 [DEBUG] [org.gradle.deployment.internal.DefaultDeploymentRegistry] Stopped deployment handles
23:42:34.645 [INFO] [org.gradle.cache.internal.DefaultPersistentDirectoryCache] VCS Checkout Cache (/Users/aaa.bbb/Documents/myApp-android/.gradle/vcsWorkingDirs) has not been cleaned up in 6 days
23:42:34.645 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache VCS Checkout Cache (/Users/aaa.bbb/Documents/myApp-android/.gradle/vcsWorkingDirs) was closed 0 times.
23:42:34.647 [DEBUG] [org.gradle.cache.internal.LockOnDemandCrossProcessCacheAccess] Releasing file lock for Artifact transforms cache (/Users/aaa.bbb/.gradle/caches/transforms-1)
23:42:34.648 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on Artifact transforms cache (/Users/aaa.bbb/.gradle/caches/transforms-1).
23:42:34.649 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache Generated Gradle JARs cache (/Users/aaa.bbb/.gradle/caches/4.6/generated-gradle-jars) was closed 0 times.
23:42:34.650 [DEBUG] [org.gradle.cache.internal.LockOnDemandCrossProcessCacheAccess] Releasing file lock for file hash cache (/Users/aaa.bbb/Documents/myApp-android/.gradle/4.6/fileHashes)
23:42:34.650 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileHashes.bin (/Users/aaa.bbb/Documents/myApp-android/.gradle/4.6/fileHashes/fileHashes.bin)
23:42:34.650 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache resourceHashesCache.bin (/Users/aaa.bbb/Documents/myApp-android/.gradle/4.6/fileHashes/resourceHashesCache.bin)
23:42:34.650 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on file hash cache (/Users/aaa.bbb/Documents/myApp-android/.gradle/4.6/fileHashes).
23:42:34.650 [DEBUG] [org.gradle.cache.internal.LockOnDemandCrossProcessCacheAccess] Releasing file lock for artifact cache (/Users/aaa.bbb/.gradle/caches/modules-2)
23:42:34.651 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-metadata.bin (/Users/aaa.bbb/.gradle/caches/modules-2/metadata-2.53/module-metadata.bin)
23:42:34.651 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-artifact.bin (/Users/aaa.bbb/.gradle/caches/modules-2/metadata-2.53/module-artifact.bin)
23:42:34.651 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-artifacts.bin (/Users/aaa.bbb/.gradle/caches/modules-2/metadata-2.53/module-artifacts.bin)
23:42:34.651 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-versions.bin (/Users/aaa.bbb/.gradle/caches/modules-2/metadata-2.53/module-versions.bin)
23:42:34.651 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on artifact cache (/Users/aaa.bbb/.gradle/caches/modules-2).
23:42:34.652 [DEBUG] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] The daemon has finished executing the build.
23:42:34.709 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientInputForwarder] Dispatching close input message: org.gradle.launcher.daemon.protocol.CloseInput@11a6bbff
23:42:34.710 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 14: dispatching class org.gradle.launcher.daemon.protocol.CloseInput
23:42:34.711 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Received result Failure[value=org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':myAppApplication:createMockDebugAndroidTestCoverageReport'.] from daemon DaemonInfo{pid=62252, address=[7ce05240-217b-4229-8733-a8232ac82e03 port:52343, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], state=Idle, lastBusy=1550549963706, context=DefaultDaemonContext[uid=6f5c8d7a-ef3c-40e2-8dea-36fe53c960bb,javaHome=/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home,daemonRegistryDir=/Users/aaa.bbb/.gradle/daemon,pid=62252,idleTimeout=10800000,daemonOpts=-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]} (build should be done).
23:42:34.711 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: dispatching class org.gradle.launcher.daemon.protocol.Finished
23:42:34.713 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: connection stop
When I checked this path: /Users/aaa.bbb/Documents/myApp-android/myAppApplication/build/reports/coverage/mock/debug on my local machine (where i have Android Studio)
Its empty. So, i think, there is no data in this path to process the coverage.
But, when i see the device (ddms) logs in the above debug snippet, i can see that the coverageFilePath = /data/data/com.chn.myApp/coverage_data/ , and when i check this path on the device, it does not exists. (the com.chn.myApp folder does not exists). Also, i could not see a remove command for this folder, so there is no chance that the folder is removed from device as part of the exit process. So, i guess, this should be an issue where the coverage report is not generated on the device.But not sure why this folder (where the coverage info is stored on the device) is not created. I am using Android emulator.
Any guidance is appreciated!
回答1:
I have found downgrading the Gradle version to 6.3 fixes the issue.
回答2:
I know it's late. But I encountered this same problem and I believe others might see the same problem.
I suppose you're following google's document and use ANDROIDX_TEST_ORCHESTRATOR
:
https://developer.android.com/training/testing/junit-runner.html#using-android-test-orchestrator
If you are, the IOException is a google's bug in the ANDROIDX_TEST_ORCHESTRATOR
https://issuetracker.google.com/issues/72758547
What I did is to just comment
//execution 'ANDROIDX_TEST_ORCHESTRATOR'
It should be able to generate code coverage.
Hope this helps
Edit 1/Dec/2020
It seems google fixed the issue at Android Gradle plugin 3.2.0-alpha17.
https://issuetracker.google.com/issues/72758547#comment17
With com.android.tools.build:gradle:4.1.1
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
ANDROIDX_TEST_ORCHESTRATOR works.
回答3:
Instead of createMockDebugAndroidTestCoverageReport
try to run connectedMockDebugAndroidTest
followed by jacocoTestReport
:
$ ./gradlew :myAppApplication:connectedMockDebugAndroidTest
$ ./gradlew :myAppApplication:jacocoTestReport
来源:https://stackoverflow.com/questions/54759384/test-coverage-report-is-not-generated-with-java-io-ioexception