realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

Invalid instrumented test code coverage for libraries when applying Realm plugin. #7749

Closed Plo4ox closed 1 year ago

Plo4ox commented 1 year ago

How frequently does the bug occur?

All the time

Description

This is a gradle plugin issue, it only happens when applying the "realm-android" plugin on an android library. No issue raised when executing it on an app.

Expected: After executing the connected android test ("mylibrary:connectedDebugAndroidTest"), the generated "coverage.ec" must not be empty.

Actually happening: After executing the connected android test, the generated "coverage.ec" is empty

Stacktrace & log output

No response

Can you reproduce the bug?

Yes, always

Reproduction Steps

Here is a link to a Github repository containing what is described in the following steps. https://github.com/Plo4ox/RealmJavaSdkIssue Branches:

Here is what can be done to reproduce the issue:

As it can be seen this is only happening with the library, thus the code coverage on the library classes is empty. This is not the case with the code coverage of the app.

Temporary workarounds:

Version

10.13.0

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

Android 12

Build environment

Android Studio version: Android Studio Dolphin | 2021.3.1 Patch 1 Android Build Tools version: 7.3.1 Gradle version: 7.4

edualonso commented 1 year ago

Hi @Plo4ox We are aware of some changes to the transformer API in AGP 7.3. Unfortunately we don't support this new API due to a bug that cannot be fixed for previous versions. We have though an experimental branch that runs with AGP 7.4 which can be found at https://central.sonatype.dev/artifact/io.realm/realm-android-library/10.12.0-transformer-api Could you try and test it with the experimental branch and AGP 7.4?

Plo4ox commented 1 year ago

Hi,

Thanks for the quick answer! I tested with 10.13.0-transformer-api, and indeed the issue seems to be fixed! 😃👍 It has been tested here https://github.com/Plo4ox/RealmJavaSdkIssue/tree/feature/working-10-13-transformer-api

@edualonso Do you know what the plans are for this experimental branch in the future?

clementetb commented 1 year ago

It will become the main branch once AGP 7.4 is released.

Plo4ox commented 1 year ago

Ok great, thanks! 😃