[英]How to add jacocoagent.jar to Android build.gradle - Failed resolution of: Lorg/jacoco/agent/rt/internal_3570298/Offline;
I have following setup我有以下设置
but when trying to run the AndroidTest and generate jacoco report, it fails with但是当尝试运行 AndroidTest 并生成 jacoco 报告时,它失败了
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jacoco/agent/rt/internal_3570298/Offline;
java.lang.NoClassDefFoundError:解析失败:Lorg/jacoco/agent/rt/internal_3570298/Offline;
After doing my research it seems I need to add jacocoagent.jar to classpath
, but how?在完成我的研究之后,我似乎需要
add jacocoagent.jar to classpath
,但是如何添加?
Tried adding testImplementation 'org.jacoco:org.jacoco.agent:0.8.7'
and also downloading jar file from search.maven.org/artifact/org.jacoco/org.jacoco.agent/0.8.7/jar and adding jacoco-agent.properties
file referencing the jar but no success :/ what am I missing...尝试添加
testImplementation 'org.jacoco:org.jacoco.agent:0.8.7'
并从 search.maven.org/artifact/org.jacoco/org.jacoco.agent/0.8.7/jar 下载 jar 文件并添加jacoco-agent.properties
文件引用 jar 但没有成功:/我错过了什么......
(things I've looked into: (我调查过的事情:
Removing Jacoco library dependency while exporting project as jar 将项目导出为 jar 时删除 Jacoco 库依赖项
how to prevent jacoco instrumenting production code? 如何防止 jacoco 检测生产代码?
https://issuetracker.google.com/issues/37116868 ) https://issuetracker.google.com/issues/37116868 )
You need to add this like of code in your build.gradle ,您需要在 build.gradle 中添加这样的代码,
testImplementation group: 'org.jacoco', name: 'org.jacoco.agent', version: '0.8.7'
or或者
testImplementation 'org.jacoco:org.jacoco.agent:0.8.7'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.