vanniktech / gradle-android-junit-jacoco-plugin

Gradle plugin that generates JaCoCo reports from an Android Gradle Project
http://vanniktech.com
Apache License 2.0
400 stars 76 forks source link

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jacoco/agent/rt/internal_3570298/Offline #209

Open root-ansh-ct opened 2 years ago

root-ansh-ct commented 2 years ago

recently I added this plugin in one of my sample projects. the coverage task works perfectly. however it has impacted the assembleRelease / assembleDebug task in a manner that the aar that is generated via this plugin is giving this runtime error.

Steps to reproduce:

  1. create a multi-modular project
  2. add the plugin in root build.gradle like this:

    
    buildscript {
    
    repositories {
        google()// Google's Maven repository
        mavenCentral()
        gradlePluginPortal()
        maven {
            url 'https://developer.huawei.com/repo/' }
    
    }
    dependencies {
        ...
        classpath("com.vanniktech:gradle-android-junit-jacoco-plugin:0.16.0")
    
    }
    }
    apply plugin: "com.vanniktech.android.junit.jacoco"

junitJacoco { jacocoVersion = '0.8.7' // type String }

3. run `gradle assembleRelease` this will generate an aar for your module at `modulename/build/outputs/aar/modulename.aar`
4. create another android project. in its `app/libs` folder add the module (`modulename.aar`)
5. in its `app/build.gradle` , add :
```groovy
dependencies {
    implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
    implementation files('libs/modulename.aar')   
     ....
}
  1. use the module's functions or something inside your app
  2. run app

note: this might be related to some android studio's AGP version , as mentioned here : https://issuetracker.google.com/issues/222338458#comment6

I am not sure if i understand it fully, but i really want to apply a quick resolution to this issue. i am using AGP version 4.2.1 and gradle version 7.0.2 .