Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)

Tags:

android

jacoco

Facing this problem while trying to implement JaCoCo Offline Instrumentation.

W/System.err( 1733): java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
W/System.err( 1733):    at libcore.io.IoBridge.open(IoBridge.java:456)
W/System.err( 1733):    at java.io.FileOutputStream.<init>(FileOutputStream.java:89)
--
W/System.err( 1733):    at libcore.io.IoBridge.open(IoBridge.java:456)
W/System.err( 1733):    at java.io.FileOutputStream.<init>(FileOutputStream.java:89)
W/System.err( 1733):    at org.jacoco.agent.rt.internal_14f7ee5.output.FileOutput.openFile(FileOutput.java:67)
W/System.err( 1733):    at org.jacoco.agent.rt.internal_14f7ee5.output.FileOutput.startup(FileOutput.java:49)
W/System.err( 1733):    at org.jacoco.agent.rt.internal_14f7ee5.Agent.startup(Agent.java:122)
W/System.err( 1733):    at org.jacoco.agent.rt.internal_14f7ee5.Agent.getInstance(Agent.java:50)
W/System.err( 1733):    at org.jacoco.agent.rt.internal_14f7ee5.Offline.<clinit>(Offline.java:31)
like image 827
Pranesh Mylraj Avatar asked May 13 '19 15:05

Pranesh Mylraj


2 Answers

The solution is well-documented in jacoco but for Android people, what you need is to add the file in /src/androidTest/resources/jacoco-agent.properties with the contents output=none so jacoco can startup without failing, and coverage will be written as normal and transferred correctly later by the android gradle plugin coverage implementation.

like image 107
Marton Gyiran Avatar answered Oct 16 '22 10:10

Marton Gyiran


I think it's safe to ignore that offline instrumentation warning, because the path should be something alike: executionData = files("${project.buildDir}/jacoco/${testTaskName}.exec") (on the PC - so there is no need to save it on the device and then pull the file).


On Android this will add the JaCoCo agent into the APK:

buildTypes {
    debug {
        testCoverageEnabled = true
    }
}
like image 2
Martin Zeitler Avatar answered Oct 16 '22 11:10

Martin Zeitler