Caused by: java.lang.IllegalStateException: JaCoCo agent not started

148 views
Skip to first unread message

sunha...@163.com

unread,
Jul 29, 2014, 6:03:40 AM7/29/14
to jac...@googlegroups.com
use jacoco, i get this error:

D/JacocoRunner( 1737): endCoverage started!
D/JacocoRunner( 1737): java.lang.reflect.InvocationTargetException
D/JacocoRunner( 1737): java.lang.reflect.InvocationTargetException
D/JacocoRunner( 1737): at java.lang.reflect.Method.invokeNative(Native Method)
D/JacocoRunner( 1737): at java.lang.reflect.Method.invoke(Method.java:525)
D/JacocoRunner( 1737): at com.alanjeon.testing.JacocoRunner.endCoverage(JacocoRunner.java:60)
D/JacocoRunner( 1737): at com.alanjeon.testing.JacocoRunner.finish(JacocoRunner.java:93)
D/JacocoRunner( 1737): at com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner$BridgeTestRunner.finish(GoogleInstrumentationTestRunner.java:264)
D/JacocoRunner( 1737): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:574)
D/JacocoRunner( 1737): at com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner.onStart(GoogleInstrumentationTestRunner.java:167)
D/JacocoRunner( 1737): at com.alanjeon.testing.JacocoRunner.onStart(JacocoRunner.java:87)
D/JacocoRunner( 1737): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
D/JacocoRunner( 1737): Caused by: java.lang.IllegalStateException: JaCoCo agent not started.
D/JacocoRunner( 1737): at org.jacoco.agent.rt.internal_932a715.Agent.getInstance(Agent.java:72)
D/JacocoRunner( 1737): at org.jacoco.agent.rt.RT.getAgent(RT.java:32)
D/JacocoRunner( 1737): ... 9 more
I/GoogleInstr( 1737): Activities that are still in CREATED to PAUSED: 0
this is my code

OutputStream out = null;
try {
out = new FileOutputStream(getCoverageFilePath(getTargetContext().getPackageName()), false);
Object agent = Class.forName("org.jacoco.agent.rt.RT").getMethod("getAgent").invoke(null);

out.write((byte[]) agent.getClass().getMethod("getExecutionData", boolean.class).invoke(agent, false));

} catch (Exception e) {
Log.d(TAG, e.toString(), e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

Marc Hoffmann

unread,
Aug 4, 2014, 5:34:08 AM8/4/14
to jac...@googlegroups.com
Hi,

this means no instrumented class has been loaded before.

Best regards,
-marc
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages