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.
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')
....
}
use the module's functions or something inside your app
run app
expected: app will run successfully and call module's functions
actual: app builds, launches and crashes. error log :
2022-06-10 00:02:01.728 work.curioustools.myword E/AndroidRuntime: FATAL EXCEPTION: main
Process: work.curioustools.myword, PID: 6741
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jacoco/agent/rt/internal_3570298/Offline;
at com.clevertap.android.sdk.CleverTapAPI$LogLevel.$jacocoInit(Unknown Source:13)
at com.clevertap.android.sdk.CleverTapAPI$LogLevel.<clinit>(Unknown Source:0)
at work.curioustools.myword.MyWordApp.ctInitLogging(MyWordApp.kt:68)
at work.curioustools.myword.MyWordApp.onCreate(MyWordApp.kt:39)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5871)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jacoco.agent.rt.internal_3570298.Offline" on path: DexPathList[[zip file "/data/app/work.curioustools.myword-qnnHMkyzWt49lic4DRwC_Q==/base.apk"],nativeLibraryDirectories=[/data/app/work.curioustools.myword-qnnHMkyzWt49lic4DRwC_Q==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
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 .
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:
add the plugin in root
build.gradle
like this:junitJacoco { jacocoVersion = '0.8.7' // type String }
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 .