简体   繁体   English

如何将 jacocoagent.jar 添加到 Android build.gradle - Failed resolution of: Lorg/jacoco/agent/rt/internal_3570298/Offline;

[英]How to add jacocoagent.jar to Android build.gradle - Failed resolution of: Lorg/jacoco/agent/rt/internal_3570298/Offline;

I have following setup我有以下设置

  • AGP 7.x+ AGP 7.x+
  • Kotlin 1.5.x+科特林 1.5.x+
  • JaCoCo 0.8.7+杰可可 0.8.7+
  • Java 11 set as the JDK Java 11 设置为 JDK
  • Java 1.8 set as jvmTarget and compileOptions Java 1.8 设置为 jvmTarget 和 compileOptions

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.

相关问题 Android App 中的异常:Lorg/jacoco/agent/rt/internal_8ff85ea/Offline 的解析失败; - Exception in Android App: Failed resolution of: Lorg/jacoco/agent/rt/internal_8ff85ea/Offline; java.lang.NoClassDefFoundError:解析失败:Lorg/jacoco/agent/rt/internal_14f7ee5/Offline - java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jacoco/agent/rt/internal_14f7ee5/Offline 解析失败:Lorg/jacoco/agent/rt/internal_8ff85ea/Offline - Failed resolution of: Lorg/jacoco/agent/rt/internal_8ff85ea/Offline java.lang.NoClassDefFoundError:解析失败:Lorg/jacoco/agent/rt/internal_773e439/Offline; - java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jacoco/agent/rt/internal_773e439/Offline; Android firebase 失败的 build.gradle 实现 - Android firebase failed build.gradle implementation 如何在Eclipse的现有Android应用上添加build.gradle - How to add build.gradle on existing Android app on Eclipse Android:build.gradle错误(“无法解决”) - Android: build.gradle error (“Failed to resolve”) 如何使用android studio将TIKA添加到build.gradle中? - How to add TIKA into build.gradle using android studio? 如何将deppendecy添加到build.gradle? - How to add a deppendecy to a build.gradle? 如何通过在Android Studio中编辑build.gradle将我的库放在android.jar前面 - How to put my libraries in front of android.jar by editing build.gradle in Android-Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM