Discussion:
[java code coverage] jacoco-agent.properties with Android Studio project
vishy
2015-10-17 04:41:14 UTC
Permalink
Hi guys,

I am investigating code-coverage for our Android app. built with Gradle and Android Studio.

I need code-coverage reports in two situations: during manual tests, and during automated tests built with our Appium suite.

I need to get a proof-of-concept that JaCoCo can indeed do code coverage in this case.

Given that we need coverage for Appium and manual tests, I believe offline-instrumentation with JaCoCo is what I need.

I have succeeded in creating an instrumented APK.
But when I run the app manually, I keep seeing errors in the logcat W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)

From JaCoCo docs as well as general Googling, I understand that Jacoco needs to know where to store the jacoco.exec file - and that I need to package a jacoco-agent.properties (containing a destfile property) with the APK.

I have tried putting jacoco-agent.properties in the "assets" folder of my app - it was packaged into the APK properly, but did not seem to have any effect (i.e Jacoco failed as usual) I tried putting it inside res - it did not get packaged into the APK. I tried res/raw and hit the error about a dash in the filename.

I am at my wit's end, and would really appreciate help. How do I package jacoco-agent.properties using my Gradle build into the APK, so that JaCoCo will read it?
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/51d07502-cd28-4516-affa-633d0ba65275%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marc R. Hoffmann
2015-10-19 17:08:12 UTC
Permalink
Hi,

the jacoco-agent.properties file has to be packaged in a way that it is
on the Java classpath.

Here is a working example for Android:
https://github.com/Godin/jacoco-experiments/tree/android/android

Regards,
-marc
Post by vishy
Hi guys,
I am investigating code-coverage for our Android app. built with Gradle and Android Studio.
I need code-coverage reports in two situations: during manual tests, and during automated tests built with our Appium suite.
I need to get a proof-of-concept that JaCoCo can indeed do code coverage in this case.
Given that we need coverage for Appium and manual tests, I believe offline-instrumentation with JaCoCo is what I need.
I have succeeded in creating an instrumented APK.
But when I run the app manually, I keep seeing errors in the logcat W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
From JaCoCo docs as well as general Googling, I understand that Jacoco needs to know where to store the jacoco.exec file - and that I need to package a jacoco-agent.properties (containing a destfile property) with the APK.
I have tried putting jacoco-agent.properties in the "assets" folder of my app - it was packaged into the APK properly, but did not seem to have any effect (i.e Jacoco failed as usual) I tried putting it inside res - it did not get packaged into the APK. I tried res/raw and hit the error about a dash in the filename.
I am at my wit's end, and would really appreciate help. How do I package jacoco-agent.properties using my Gradle build into the APK, so that JaCoCo will read it?
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/5625237C.6030802%40mountainminds.com.
For more options, visit https://groups.google.com/d/optout.
v***@icelero.com
2015-10-26 06:18:20 UTC
Permalink
Post by Marc R. Hoffmann
the jacoco-agent.properties file has to be packaged in a way that it is
on the Java classpath.
True, I realized as much.
Post by Marc R. Hoffmann
https://github.com/Godin/jacoco-experiments/tree/android/android
Thanks. I did come across that in my searches, but that example is for Maven. I am unable to figure out how to do the same with Gradle (Android Studio uses Gradle)

I asked the same question in StackOverflow, the reply I received did not work.
(http://stackoverflow.com/questions/33182667/packaging-jacoco-agent-properties-into-an-apk-so-it-can-be-read)
Post by Marc R. Hoffmann
Regards,
-marc
Post by vishy
Hi guys,
I am investigating code-coverage for our Android app. built with Gradle and Android Studio.
I need code-coverage reports in two situations: during manual tests, and during automated tests built with our Appium suite.
I need to get a proof-of-concept that JaCoCo can indeed do code coverage in this case.
Given that we need coverage for Appium and manual tests, I believe offline-instrumentation with JaCoCo is what I need.
I have succeeded in creating an instrumented APK.
But when I run the app manually, I keep seeing errors in the logcat W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
From JaCoCo docs as well as general Googling, I understand that Jacoco needs to know where to store the jacoco.exec file - and that I need to package a jacoco-agent.properties (containing a destfile property) with the APK.
I have tried putting jacoco-agent.properties in the "assets" folder of my app - it was packaged into the APK properly, but did not seem to have any effect (i.e Jacoco failed as usual) I tried putting it inside res - it did not get packaged into the APK. I tried res/raw and hit the error about a dash in the filename.
I am at my wit's end, and would really appreciate help. How do I package jacoco-agent.properties using my Gradle build into the APK, so that JaCoCo will read it?
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/aad412b6-62e4-4fdb-8e7d-5dbc8d540569%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
a***@tsepak.com
2015-11-02 14:50:43 UTC
Permalink
Hi,

I want to use jacoco for my appium test cases and manual testing using gradle. can you please help me about how to do it.?

Regards,
Anuja
--
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
Any views expressed by the sender in this communication are those of the
sender alone and do not necessarily express the views or the policy of the
organization unless intended to do so. If you are not the named addressee
you should not disseminate, distribute or copy this e-mail. If you have
received this email in error please immediately notify ****@tsepak.com
<***@tsepak.com>* and delete this email from your system. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
information is strictly prohibited. Thank you.
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/efceb4d2-1ccc-43a4-9ab5-5d421391cbbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Vishwanath Venugopalakrishnan
2015-11-03 02:49:11 UTC
Permalink
Hi guys,

I guess from the latest update, it is clear that there is a gap in
documentation for Jacoco - specifically in regards to making Jacoco work
with Android Studio / Gradle for Manual Testing.

Existing docs either deal with code coverage for unit testing (doesn't
apply to my case) or for an Ant/Maven setup (again does not apply).

An earnest appeal to the more knowledgeable folks out there to write a
clear doc explaining how to make this combination work.
Thanks!
Post by a***@tsepak.com
Hi,
I want to use jacoco for my appium test cases and manual testing using
gradle. can you please help me about how to do it.?
Regards,
Anuja
--
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
Any views expressed by the sender in this communication are those of the
sender alone and do not necessarily express the views or the policy of the
organization unless intended to do so. If you are not the named addressee
you should not disseminate, distribute or copy this e-mail. If you have
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
information is strictly prohibited. Thank you.
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/CAL70z%2BpHCYD3nuG1EjzjYiB-7yd%3DjKzFd-AkmpNQKS3OnqL8VA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
a***@tsepak.com
2015-11-06 09:02:22 UTC
Permalink
Hi,

As you said you managed to configure the jacoco with gradle with appium suit.
I am trying to do the same can you please share some more information on how you did it. It will be really helpful.

Thanks,
Anuja
--
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
Any views expressed by the sender in this communication are those of the
sender alone and do not necessarily express the views or the policy of the
organization unless intended to do so. If you are not the named addressee
you should not disseminate, distribute or copy this e-mail. If you have
received this email in error please immediately notify ****@tsepak.com
<***@tsepak.com>* and delete this email from your system. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
information is strictly prohibited. Thank you.
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/e65e39b4-4efb-42ff-8230-6481becb4c47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Vishwanath Venugopalakrishnan
2015-11-06 09:03:37 UTC
Permalink
Actually, you might want to read more carefully.

What I said was:

I am *unable *to figure out how to do the same with Gradle (Android Studio
Post by v***@icelero.com
uses Gradle)
I asked the same question in StackOverflow, the reply I received did not
work.
(
http://stackoverflow.com/questions/33182667/packaging-jacoco-agent-properties-into-an-apk-so-it-can-be-read
)
Hi,
As you said you managed to configure the jacoco with gradle with appium suit.
I am trying to do the same can you please share some more information on
how you did it. It will be really helpful.
Thanks,
Anuja
--
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
Any views expressed by the sender in this communication are those of the
sender alone and do not necessarily express the views or the policy of the
organization unless intended to do so. If you are not the named addressee
you should not disseminate, distribute or copy this e-mail. If you have
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
information is strictly prohibited. Thank you.
--
Vish Venugopalakrishnan
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/CAL70z%2BruFqh-QpKFgyPtTXFjcg8HEq3D6o1dLm6n1r0%2BYymtPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
m***@openscg.com
2015-12-03 14:42:33 UTC
Permalink
Post by vishy
Hi guys,
I am investigating code-coverage for our Android app. built with Gradle and Android Studio.
I need code-coverage reports in two situations: during manual tests, and during automated tests built with our Appium suite.
I need to get a proof-of-concept that JaCoCo can indeed do code coverage in this case.
Given that we need coverage for Appium and manual tests, I believe offline-instrumentation with JaCoCo is what I need.
I have succeeded in creating an instrumented APK.
But when I run the app manually, I keep seeing errors in the logcat W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
From JaCoCo docs as well as general Googling, I understand that Jacoco needs to know where to store the jacoco.exec file - and that I need to package a jacoco-agent.properties (containing a destfile property) with the APK.
I have tried putting jacoco-agent.properties in the "assets" folder of my app - it was packaged into the APK properly, but did not seem to have any effect (i.e Jacoco failed as usual) I tried putting it inside res - it did not get packaged into the APK. I tried res/raw and hit the error about a dash in the filename.
I am at my wit's end, and would really appreciate help. How do I package jacoco-agent.properties using my Gradle build into the APK, so that JaCoCo will read it?
Hi,

Could you provide me the build.gradle code to get the instrumented apk,
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/4e913dd9-de23-469a-833d-187c36086e5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
a***@gmail.com
2015-12-18 08:16:43 UTC
Permalink
You can achieve code coverage of android apk using gradle and jacoco, by following below steps.

1.Configuring JaCoCo plugin in build.gradle (present inside 'app' folder ) as below
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.7.4+"
}
2. Enable Jacoco code coverage on the debug build in build.gradle (present inside 'app' folder ) at 'buildTypes' as below

debug {
testCoverageEnabled true
}
3. Add below line in your 'app/src/main/AndroidManifest.xml ' to access sdcard for writting coverage data
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
4. Add below lines in 'MainActivity.java' at end
protected void onStop()
{
super.onStop();
if(BuildConfig.DEBUG)
{
try {
Class<?> emmaRTClass = Class.forName("com.vladium.emma.rt.RT");
Method dumpCoverageMethod = emmaRTClass.getMethod("dumpCoverageData",coverageFile.getClass(), boolean.class, boolean.class);
dumpCoverageMethod.invoke(null, "/sdcard/coverage.exec", ture, false);
} catch (Exception e) {}
}
}
5.Build debug apk.
6..Install this apk in your device , and to do the test.
7.After testing kill your app.
8.Connect device with computer, run below command to get coverage data file from device
'adb pull /sdcard/coverage.exec'
9.Genrate coverage report using ant(with jacoco task) or jenkings (jacoco plugin) by using following:-
Copy classes from "D:\coverage\app\build\intermediates\classes\debug"
Copy source from "D:\coverage\app\\src\main\java"
Copy exec file from "D:\coverage\mycoverage.exec"
Add below as Exclusions:-
**/R.class,**/R$*.class,**/BuildConfig.*,**/Manifest*.*,**/*Fragment*.*,**/*Activity$*.*


Thanks
Abhishek Gupta
Post by vishy
Hi guys,
I am investigating code-coverage for our Android app. built with Gradle and Android Studio.
I need code-coverage reports in two situations: during manual tests, and during automated tests built with our Appium suite.
I need to get a proof-of-concept that JaCoCo can indeed do code coverage in this case.
Given that we need coverage for Appium and manual tests, I believe offline-instrumentation with JaCoCo is what I need.
I have succeeded in creating an instrumented APK.
But when I run the app manually, I keep seeing errors in the logcat W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
From JaCoCo docs as well as general Googling, I understand that Jacoco needs to know where to store the jacoco.exec file - and that I need to package a jacoco-agent.properties (containing a destfile property) with the APK.
I have tried putting jacoco-agent.properties in the "assets" folder of my app - it was packaged into the APK properly, but did not seem to have any effect (i.e Jacoco failed as usual) I tried putting it inside res - it did not get packaged into the APK. I tried res/raw and hit the error about a dash in the filename.
I am at my wit's end, and would really appreciate help. How do I package jacoco-agent.properties using my Gradle build into the APK, so that JaCoCo will read it?
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/66a5b5af-8987-46a3-9902-0b6e0c7e079c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Annam, Mohan Reddy
2016-01-13 00:44:38 UTC
Permalink
Hi All,

1) Could you please let us know, how to add exclusions like Add below as
Exclusions:-

**/R.class,**/R$*.class,**/BuildConfig.*,**/Manifest*.*,**/*Fragment*.*,**/*Activity$*.*
in the java class .

2) I had hot coded the device path say /mnt/sdcard/ in the jacoco source
code and rebuild the jar and used it as jacoco default takes path as / to
store jacoco.exec.

How to pass the path as argument to android ?

Thanks
Mohan
Post by a***@gmail.com
You can achieve code coverage of android apk using gradle and jacoco, by
following below steps.
1.Configuring JaCoCo plugin in build.gradle (present inside 'app' folder ) as below
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.7.4+"
}
2. Enable Jacoco code coverage on the debug build in build.gradle
(present inside 'app' folder ) at 'buildTypes' as below
debug {
testCoverageEnabled true
}
3. Add below line in your 'app/src/main/AndroidManifest.xml ' to access
sdcard for writting coverage data
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
4. Add below lines in 'MainActivity.java' at end
protected void onStop()
{
super.onStop();
if(BuildConfig.DEBUG)
{
try {
Class<?> emmaRTClass =
Class.forName("com.vladium.emma.rt.RT");
Method dumpCoverageMethod =
emmaRTClass.getMethod("dumpCoverageData",coverageFile.getClass(),
boolean.class, boolean.class);
dumpCoverageMethod.invoke(null,
"/sdcard/coverage.exec", ture, false);
} catch (Exception e) {}
}
}
5.Build debug apk.
6..Install this apk in your device , and to do the test.
7.After testing kill your app.
8.Connect device with computer, run below command to get coverage data file from device
'adb pull /sdcard/coverage.exec'
9.Genrate coverage report using ant(with jacoco task) or jenkings (jacoco
plugin) by using following:-
Copy classes from "D:\coverage\app\build\intermediates\classes\debug"
Copy source from "D:\coverage\app\\src\main\java"
Copy exec file from "D:\coverage\mycoverage.exec"
Add below as Exclusions:-
**/R.class,**/R$*.class,**/BuildConfig.*,**/Manifest*.*,**/*Fragment*.*,**/*Activity$*.*
Thanks
Abhishek Gupta
Post by vishy
Hi guys,
I am investigating code-coverage for our Android app. built with Gradle
and Android Studio.
Post by vishy
I need code-coverage reports in two situations: during manual tests, and
during automated tests built with our Appium suite.
Post by vishy
I need to get a proof-of-concept that JaCoCo can indeed do code coverage
in this case.
Post by vishy
Given that we need coverage for Appium and manual tests, I believe
offline-instrumentation with JaCoCo is what I need.
Post by vishy
I have succeeded in creating an instrumented APK.
But when I run the app manually, I keep seeing errors in the logcat
EROFS (Read-only file system)
Post by vishy
From JaCoCo docs as well as general Googling, I understand that Jacoco
needs to know where to store the jacoco.exec file - and that I need to
package a jacoco-agent.properties (containing a destfile property) with the
APK.
Post by vishy
I have tried putting jacoco-agent.properties in the "assets" folder of
my app - it was packaged into the APK properly, but did not seem to have
any effect (i.e Jacoco failed as usual) I tried putting it inside res - it
did not get packaged into the APK. I tried res/raw and hit the error about
a dash in the filename.
Post by vishy
I am at my wit's end, and would really appreciate help. How do I package
jacoco-agent.properties using my Gradle build into the APK, so that JaCoCo
will read it?
--
You received this message because you are subscribed to a topic in the
Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/jacoco/vx0g_6TKY8Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/66a5b5af-8987-46a3-9902-0b6e0c7e079c%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/CAP_M%3DRqmEd0eOZ3KEiGweFstWCGsd3eBUN8y_TUF2AOBQeZjdg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
abhishek gupta
2016-01-13 07:08:11 UTC
Permalink
For making exec file configurable you need use build variables
To define variable in build.gradle (present inside 'app' folder ) at
'buildTypes' add following for both build types
buildConfigField "String", "exec_name", "\"mycoverage.exec\""
Then access this variable in your 'MainActivity.java' using
'BuildConfig.exec_name'


To generate report using build.gradle , add one task as below in
build.gradle (present inside 'app' folder )

task jacocoTestReport(type: JacocoReport) {
def coverageSourceDirs = [
'src/main/java'
]
group = "Reporting"
description = "Generates Jacoco coverage reports"
reports {
csv.enabled false
xml{
enabled = true
destination "${buildDir}/jacoco/jacoco.xml"
}
html{
enabled true
destination "${buildDir}/jacocoHtml"
}
}
classDirectories = fileTree(
dir: 'build/intermediates/classes',
excludes: ['**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Activity*.*',
'**/*Fragment*.*'
]
)
sourceDirectories = files(coverageSourceDirs)
executionData = files('coverage.exec')
}



Thanks
Abhishek
Post by Annam, Mohan Reddy
Hi All,
1) Could you please let us know, how to add exclusions like Add below as
Exclusions:-
**/R.class,**/R$*.class,**/BuildConfig.*,**/Manifest*.*,**/*Fragment*.*,**/*Activity$*.*
in the java class .
2) I had hot coded the device path say /mnt/sdcard/ in the jacoco source
code and rebuild the jar and used it as jacoco default takes path as / to
store jacoco.exec.
How to pass the path as argument to android ?
Thanks
Mohan
Post by a***@gmail.com
You can achieve code coverage of android apk using gradle and jacoco, by
following below steps.
1.Configuring JaCoCo plugin in build.gradle (present inside 'app' folder ) as below
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.7.4+"
}
2. Enable Jacoco code coverage on the debug build in build.gradle
(present inside 'app' folder ) at 'buildTypes' as below
debug {
testCoverageEnabled true
}
3. Add below line in your 'app/src/main/AndroidManifest.xml ' to access
sdcard for writting coverage data
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
4. Add below lines in 'MainActivity.java' at end
protected void onStop()
{
super.onStop();
if(BuildConfig.DEBUG)
{
try {
Class<?> emmaRTClass =
Class.forName("com.vladium.emma.rt.RT");
Method dumpCoverageMethod =
emmaRTClass.getMethod("dumpCoverageData",coverageFile.getClass(),
boolean.class, boolean.class);
dumpCoverageMethod.invoke(null,
"/sdcard/coverage.exec", ture, false);
} catch (Exception e) {}
}
}
5.Build debug apk.
6..Install this apk in your device , and to do the test.
7.After testing kill your app.
8.Connect device with computer, run below command to get coverage data file from device
'adb pull /sdcard/coverage.exec'
9.Genrate coverage report using ant(with jacoco task) or jenkings (jacoco
plugin) by using following:-
Copy classes from "D:\coverage\app\build\intermediates\classes\debug"
Copy source from "D:\coverage\app\\src\main\java"
Copy exec file from "D:\coverage\mycoverage.exec"
Add below as Exclusions:-
**/R.class,**/R$*.class,**/BuildConfig.*,**/Manifest*.*,**/*Fragment*.*,**/*Activity$*.*
Thanks
Abhishek Gupta
Post by vishy
Hi guys,
I am investigating code-coverage for our Android app. built with Gradle
and Android Studio.
Post by vishy
I need code-coverage reports in two situations: during manual tests,
and during automated tests built with our Appium suite.
Post by vishy
I need to get a proof-of-concept that JaCoCo can indeed do code
coverage in this case.
Post by vishy
Given that we need coverage for Appium and manual tests, I believe
offline-instrumentation with JaCoCo is what I need.
Post by vishy
I have succeeded in creating an instrumented APK.
But when I run the app manually, I keep seeing errors in the logcat
EROFS (Read-only file system)
Post by vishy
From JaCoCo docs as well as general Googling, I understand that Jacoco
needs to know where to store the jacoco.exec file - and that I need to
package a jacoco-agent.properties (containing a destfile property) with the
APK.
Post by vishy
I have tried putting jacoco-agent.properties in the "assets" folder of
my app - it was packaged into the APK properly, but did not seem to have
any effect (i.e Jacoco failed as usual) I tried putting it inside res - it
did not get packaged into the APK. I tried res/raw and hit the error about
a dash in the filename.
Post by vishy
I am at my wit's end, and would really appreciate help. How do I
package jacoco-agent.properties using my Gradle build into the APK, so that
JaCoCo will read it?
--
You received this message because you are subscribed to a topic in the
Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/jacoco/vx0g_6TKY8Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/66a5b5af-8987-46a3-9902-0b6e0c7e079c%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the
Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/jacoco/vx0g_6TKY8Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/CAP_M%3DRqmEd0eOZ3KEiGweFstWCGsd3eBUN8y_TUF2AOBQeZjdg%40mail.gmail.com
<https://groups.google.com/d/msgid/jacoco/CAP_M%3DRqmEd0eOZ3KEiGweFstWCGsd3eBUN8y_TUF2AOBQeZjdg%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/CAN-5WUp1OHNcoxzazWMU3EsxJSoUSEg2bjHq-%2Bstj080dZG5sQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
r***@gmail.com
2016-03-25 09:21:18 UTC
Permalink
Post by a***@gmail.com
You can achieve code coverage of android apk using gradle and jacoco, by following below steps.
1.Configuring JaCoCo plugin in build.gradle (present inside 'app' folder ) as below
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.7.4+"
}
2. Enable Jacoco code coverage on the debug build in build.gradle (present inside 'app' folder ) at 'buildTypes' as below
debug {
testCoverageEnabled true
}
3. Add below line in your 'app/src/main/AndroidManifest.xml ' to access sdcard for writting coverage data
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
4. Add below lines in 'MainActivity.java' at end
protected void onStop()
{
super.onStop();
if(BuildConfig.DEBUG)
{
try {
Class<?> emmaRTClass = Class.forName("com.vladium.emma.rt.RT");
Method dumpCoverageMethod = emmaRTClass.getMethod("dumpCoverageData",coverageFile.getClass(), boolean.class, boolean.class);
dumpCoverageMethod.invoke(null, "/sdcard/coverage.exec", ture, false);
} catch (Exception e) {}
}
}
5.Build debug apk.
6..Install this apk in your device , and to do the test.
7.After testing kill your app.
8.Connect device with computer, run below command to get coverage data file from device
'adb pull /sdcard/coverage.exec'
9.Genrate coverage report using ant(with jacoco task) or jenkings (jacoco plugin) by using following:-
Copy classes from "D:\coverage\app\build\intermediates\classes\debug"
Copy source from "D:\coverage\app\\src\main\java"
Copy exec file from "D:\coverage\mycoverage.exec"
Add below as Exclusions:-
**/R.class,**/R$*.class,**/BuildConfig.*,**/Manifest*.*,**/*Fragment*.*,**/*Activity$*.*
Thanks
Abhishek Gupta
Post by vishy
Hi guys,
I am investigating code-coverage for our Android app. built with Gradle and Android Studio.
I need code-coverage reports in two situations: during manual tests, and during automated tests built with our Appium suite.
I need to get a proof-of-concept that JaCoCo can indeed do code coverage in this case.
Given that we need coverage for Appium and manual tests, I believe offline-instrumentation with JaCoCo is what I need.
I have succeeded in creating an instrumented APK.
But when I run the app manually, I keep seeing errors in the logcat W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
From JaCoCo docs as well as general Googling, I understand that Jacoco needs to know where to store the jacoco.exec file - and that I need to package a jacoco-agent.properties (containing a destfile property) with the APK.
I have tried putting jacoco-agent.properties in the "assets" folder of my app - it was packaged into the APK properly, but did not seem to have any effect (i.e Jacoco failed as usual) I tried putting it inside res - it did not get packaged into the APK. I tried res/raw and hit the error about a dash in the filename.
I am at my wit's end, and would really appreciate help. How do I package jacoco-agent.properties using my Gradle build into the APK, so that JaCoCo will read it?
Did it work for any .. esp Vishy as I am also facing same issue as Vishy..

Thanks,
Ramdas
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/6c4a0128-0e0e-49d1-8306-88380eaac6ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
p***@gmail.com
2016-08-04 08:39:04 UTC
Permalink
Post by r***@gmail.com
Post by a***@gmail.com
You can achieve code coverage of android apk using gradle and jacoco, by following below steps.
1.Configuring JaCoCo plugin in build.gradle (present inside 'app' folder ) as below
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.7.4+"
}
2. Enable Jacoco code coverage on the debug build in build.gradle (present inside 'app' folder ) at 'buildTypes' as below
debug {
testCoverageEnabled true
}
3. Add below line in your 'app/src/main/AndroidManifest.xml ' to access sdcard for writting coverage data
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
4. Add below lines in 'MainActivity.java' at end
protected void onStop()
{
super.onStop();
if(BuildConfig.DEBUG)
{
try {
Class<?> emmaRTClass = Class.forName("com.vladium.emma.rt.RT");
Method dumpCoverageMethod = emmaRTClass.getMethod("dumpCoverageData",coverageFile.getClass(), boolean.class, boolean.class);
dumpCoverageMethod.invoke(null, "/sdcard/coverage.exec", ture, false);
} catch (Exception e) {}
}
}
5.Build debug apk.
6..Install this apk in your device , and to do the test.
7.After testing kill your app.
8.Connect device with computer, run below command to get coverage data file from device
'adb pull /sdcard/coverage.exec'
9.Genrate coverage report using ant(with jacoco task) or jenkings (jacoco plugin) by using following:-
Copy classes from "D:\coverage\app\build\intermediates\classes\debug"
Copy source from "D:\coverage\app\\src\main\java"
Copy exec file from "D:\coverage\mycoverage.exec"
Add below as Exclusions:-
**/R.class,**/R$*.class,**/BuildConfig.*,**/Manifest*.*,**/*Fragment*.*,**/*Activity$*.*
Thanks
Abhishek Gupta
Post by vishy
Hi guys,
I am investigating code-coverage for our Android app. built with Gradle and Android Studio.
I need code-coverage reports in two situations: during manual tests, and during automated tests built with our Appium suite.
I need to get a proof-of-concept that JaCoCo can indeed do code coverage in this case.
Given that we need coverage for Appium and manual tests, I believe offline-instrumentation with JaCoCo is what I need.
I have succeeded in creating an instrumented APK.
But when I run the app manually, I keep seeing errors in the logcat W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
From JaCoCo docs as well as general Googling, I understand that Jacoco needs to know where to store the jacoco.exec file - and that I need to package a jacoco-agent.properties (containing a destfile property) with the APK.
I have tried putting jacoco-agent.properties in the "assets" folder of my app - it was packaged into the APK properly, but did not seem to have any effect (i.e Jacoco failed as usual) I tried putting it inside res - it did not get packaged into the APK. I tried res/raw and hit the error about a dash in the filename.
I am at my wit's end, and would really appreciate help. How do I package jacoco-agent.properties using my Gradle build into the APK, so that JaCoCo will read it?
Did it work for any .. esp Vishy as I am also facing same issue as Vishy..
Thanks,
Ramdas
Is there any way to get offline instrumentation done with jacoco using gradle?
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/0fc40288-0d32-4226-935e-a6e95b44f697%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sridevi Aishwariya
2016-08-31 16:30:45 UTC
Permalink
This was working for me for collecting code coverage data from Calabash
Android automation. But now it stopped, i keep getting the error,

E/Code Coverage: Failed to generate emma coverage. Is emma jar on classpath?

java.lang.ClassNotFoundException: com.vladium.emma.rt.RT
Post by a***@gmail.com
You can achieve code coverage of android apk using gradle and jacoco, by
following below steps.
1.Configuring JaCoCo plugin in build.gradle (present inside 'app' folder ) as below
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.7.4+"
}
2. Enable Jacoco code coverage on the debug build in build.gradle
(present inside 'app' folder ) at 'buildTypes' as below
debug {
testCoverageEnabled true
}
3. Add below line in your 'app/src/main/AndroidManifest.xml ' to access
sdcard for writting coverage data
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
4. Add below lines in 'MainActivity.java' at end
protected void onStop()
{
super.onStop();
if(BuildConfig.DEBUG)
{
try {
Class<?> emmaRTClass =
Class.forName("com.vladium.emma.rt.RT");
Method dumpCoverageMethod =
emmaRTClass.getMethod("dumpCoverageData",coverageFile.getClass(),
boolean.class, boolean.class);
dumpCoverageMethod.invoke(null,
"/sdcard/coverage.exec", ture, false);
} catch (Exception e) {}
}
}
5.Build debug apk.
6..Install this apk in your device , and to do the test.
7.After testing kill your app.
8.Connect device with computer, run below command to get coverage data file from device
'adb pull /sdcard/coverage.exec'
9.Genrate coverage report using ant(with jacoco task) or jenkings (jacoco
plugin) by using following:-
Copy classes from "D:\coverage\app\build\intermediates\classes\debug"
Copy source from "D:\coverage\app\\src\main\java"
Copy exec file from "D:\coverage\mycoverage.exec"
Add below as Exclusions:-
**/R.class,**/R$*.class,**/BuildConfig.*,**/Manifest*.*,**/*Fragment*.*,**/*Activity$*.*
Thanks
Abhishek Gupta
Post by vishy
Hi guys,
I am investigating code-coverage for our Android app. built with Gradle
and Android Studio.
Post by vishy
I need code-coverage reports in two situations: during manual tests, and
during automated tests built with our Appium suite.
Post by vishy
I need to get a proof-of-concept that JaCoCo can indeed do code coverage
in this case.
Post by vishy
Given that we need coverage for Appium and manual tests, I believe
offline-instrumentation with JaCoCo is what I need.
Post by vishy
I have succeeded in creating an instrumented APK.
But when I run the app manually, I keep seeing errors in the logcat
EROFS (Read-only file system)
Post by vishy
From JaCoCo docs as well as general Googling, I understand that Jacoco
needs to know where to store the jacoco.exec file - and that I need to
package a jacoco-agent.properties (containing a destfile property) with the
APK.
Post by vishy
I have tried putting jacoco-agent.properties in the "assets" folder of
my app - it was packaged into the APK properly, but did not seem to have
any effect (i.e Jacoco failed as usual) I tried putting it inside res - it
did not get packaged into the APK. I tried res/raw and hit the error about
a dash in the filename.
Post by vishy
I am at my wit's end, and would really appreciate help. How do I package
jacoco-agent.properties using my Gradle build into the APK, so that JaCoCo
will read it?
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/e594fc75-7e96-4471-a688-9f8d2ead8584%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
a***@gmail.com
2016-08-31 17:12:01 UTC
Permalink
This was working for me for collecting code coverage data from Calabash Android automation. But now it stopped, i keep getting the error,
E/Code Coverage: Failed to generate emma coverage. Is emma jar on classpath?
                                                                     java.lang.ClassNotFoundException: com.vladium.emma.rt.RT
1.Configuring JaCoCo plugin in build.gradle (present inside 'app' folder ) as below
    apply plugin: 'jacoco'
    jacoco {
        toolVersion = "0.7.4+"
    }
 2. Enable Jacoco code coverage on the debug build in build.gradle (present inside 'app' folder ) at 'buildTypes' as below
        debug {
                testCoverageEnabled true
                }
3. Add below line in your 'app/src/main/AndroidManifest.xml ' to access sdcard for writting coverage data
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
4. Add below lines in 'MainActivity.java' at end
    protected void onStop()
    {
        super.onStop();
        if(BuildConfig.DEBUG)
        {
                try {
                        Class<?> emmaRTClass = Class.forName("com.vladium.emma.rt.RT");
                        Method dumpCoverageMethod = emmaRTClass.getMethod("dumpCoverageData",coverageFile.getClass(), boolean.class, boolean.class);
                        dumpCoverageMethod.invoke(null, "/sdcard/coverage.exec", ture, false);
                    } catch (Exception e) {}  
        }        
     }
5.Build debug apk.
6..Install this apk in your device , and to do the test.
7.After testing kill your app.
8.Connect device with computer, run below command to get coverage data file from device
          'adb pull /sdcard/coverage.exec'
9.Genrate coverage report using ant(with jacoco task) or jenkings (jacoco plugin) by using following:-
     Copy classes from "D:\coverage\app\build\intermediates\classes\debug"
     Copy source from "D:\coverage\app\\src\main\java"
     Copy exec file from "D:\coverage\mycoverage.exec"
     Add below as Exclusions:-
      **/R.class,**/R$*.class,**/BuildConfig.*,**/Manifest*.*,**/*Fragment*.*,**/*Activity$*.*        
        
Thanks
Abhishek  Gupta
Post by vishy
Hi guys,
I am investigating code-coverage for our Android app. built with Gradle and Android Studio.
I need code-coverage reports in two situations: during manual tests, and during automated tests built with our Appium suite.
I need to get a proof-of-concept that JaCoCo can indeed do code coverage in this case.
Given that we need coverage for Appium and manual tests, I believe offline-instrumentation with JaCoCo is what I need.
I have succeeded in creating an instrumented APK.
But when I run the app manually, I keep seeing errors in the logcat W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
From JaCoCo docs as well as general Googling, I understand that Jacoco needs to know where to store the jacoco.exec file - and that I need to package a jacoco-agent.properties (containing a destfile property) with the APK.
I have tried putting jacoco-agent.properties in the "assets" folder of my app - it was packaged into the APK properly, but did not seem to have any effect (i.e Jacoco failed as usual) I tried putting it inside res - it did not get packaged into the APK. I tried res/raw and hit the error about a dash in the filename.
I am at my wit's end, and would really appreciate help. How do I package jacoco-agent.properties using my Gradle build into the APK, so that JaCoCo will read it?
Problem with android-studio, build your project using gradle assemble.
it will work.
I need to check why this error is coming , while building in android-studio.
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/73ac85da-3abc-40ae-aa7f-add56ff9f5a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
a***@gmail.com
2016-09-01 15:32:54 UTC
Permalink
Post by a***@gmail.com
This was working for me for collecting code coverage data from Calabash Android automation. But now it stopped, i keep getting the error,
E/Code Coverage: Failed to generate emma coverage. Is emma jar on classpath?
                                                                     java.lang.ClassNotFoundException: com.vladium.emma.rt.RT
1.Configuring JaCoCo plugin in build.gradle (present inside 'app' folder ) as below
    apply plugin: 'jacoco'
    jacoco {
        toolVersion = "0.7.4+"
    }
 2. Enable Jacoco code coverage on the debug build in build.gradle (present inside 'app' folder ) at 'buildTypes' as below
        debug {
                testCoverageEnabled true
                }
3. Add below line in your 'app/src/main/AndroidManifest.xml ' to access sdcard for writting coverage data
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
4. Add below lines in 'MainActivity.java' at end
    protected void onStop()
    {
        super.onStop();
        if(BuildConfig.DEBUG)
        {
                try {
                        Class<?> emmaRTClass = Class.forName("com.vladium.emma.rt.RT");
                        Method dumpCoverageMethod = emmaRTClass.getMethod("dumpCoverageData",coverageFile.getClass(), boolean.class, boolean.class);
                        dumpCoverageMethod.invoke(null, "/sdcard/coverage.exec", ture, false);
                    } catch (Exception e) {}  
        }        
     }
5.Build debug apk.
6..Install this apk in your device , and to do the test.
7.After testing kill your app.
8.Connect device with computer, run below command to get coverage data file from device
          'adb pull /sdcard/coverage.exec'
9.Genrate coverage report using ant(with jacoco task) or jenkings (jacoco plugin) by using following:-
     Copy classes from "D:\coverage\app\build\intermediates\classes\debug"
     Copy source from "D:\coverage\app\\src\main\java"
     Copy exec file from "D:\coverage\mycoverage.exec"
     Add below as Exclusions:-
      **/R.class,**/R$*.class,**/BuildConfig.*,**/Manifest*.*,**/*Fragment*.*,**/*Activity$*.*        
        
Thanks
Abhishek  Gupta
Post by vishy
Hi guys,
I am investigating code-coverage for our Android app. built with Gradle and Android Studio.
I need code-coverage reports in two situations: during manual tests, and during automated tests built with our Appium suite.
I need to get a proof-of-concept that JaCoCo can indeed do code coverage in this case.
Given that we need coverage for Appium and manual tests, I believe offline-instrumentation with JaCoCo is what I need.
I have succeeded in creating an instrumented APK.
But when I run the app manually, I keep seeing errors in the logcat W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
From JaCoCo docs as well as general Googling, I understand that Jacoco needs to know where to store the jacoco.exec file - and that I need to package a jacoco-agent.properties (containing a destfile property) with the APK.
I have tried putting jacoco-agent.properties in the "assets" folder of my app - it was packaged into the APK properly, but did not seem to have any effect (i.e Jacoco failed as usual) I tried putting it inside res - it did not get packaged into the APK. I tried res/raw and hit the error about a dash in the filename.
I am at my wit's end, and would really appreciate help. How do I package jacoco-agent.properties using my Gradle build into the APK, so that JaCoCo will read it?
Problem with android-studio, build your project using gradle assemble.
it will work.
I need to check why this error is coming , while building in android-studio.
use latest version of android studio (version 2.1.3).
http://tools.android.com/download/studio/builds/2-1-3
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/77398739-beb2-4883-aafa-1521056f006f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...