We recently bumped our Android app to
Realm 10.16.0
Kotlin 1.8.21
Gradle 8.0.2
kotlinCompilerExtensionVersion 1.4.7
And due to some kapt related error we also had to specifically set Java to the app and its modules like:
With this setup we are getting an error when trying to run our unit tests and these unit tests use Java objects that include the LinkingObjects annotation:
java.lang.IllegalAccessError: Update to non-static final field com.example.myapplication.objects.Dog.owners attempted from a different method (realmSet$owners) than the initializer method <init>
converting the related Java objects to Kotlin ones
Unfortunately both solutions are risky or hacky (the first one) or require too much work (the second one) and are not acceptable for the time being.
Stacktrace & log output
java.lang.IllegalAccessError: Update to non-static final field com.example.myapplication.objects.Dog.owners attempted from a different method (realmSet$owners) than the initializer method <init>
Can you reproduce the bug?
Always
Reproduction Steps
For this reason I created a demo project based on the same setup as our project which demonstrates the same behaviour
MyApplication.zip
I've got the same problem with my Java application after upgrading to AGP 8.0.2 and Java 17. Do you still use workarounds to solve it or we have any chance to get it fixed?
How frequently does the bug occur?
Always
Description
We recently bumped our Android app to Realm 10.16.0 Kotlin 1.8.21 Gradle 8.0.2 kotlinCompilerExtensionVersion 1.4.7 And due to some kapt related error we also had to specifically set Java to the app and its modules like:
With this setup we are getting an error when trying to run our unit tests and these unit tests use Java objects that include the LinkingObjects annotation:
java.lang.IllegalAccessError: Update to non-static final field com.example.myapplication.objects.Dog.owners attempted from a different method (realmSet$owners) than the initializer method <init>
This error maybe related to these ones: https://github.com/realm/realm-java/issues/7799 https://github.com/realm/realm-java/issues/7804
Two workarounds that we tried and worked are
instead of:
Unfortunately both solutions are risky or hacky (the first one) or require too much work (the second one) and are not acceptable for the time being.
Stacktrace & log output
Can you reproduce the bug?
Always
Reproduction Steps
For this reason I created a demo project based on the same setup as our project which demonstrates the same behaviour MyApplication.zip
Version
Android 13
What Atlas App Services are you using?
Local Database only
Are you using encryption?
Yes
Platform OS and version(s)
Android 13
Build environment
Android Studio version: Flamingo | 2022.2.1 Realm 10.16.0 Kotlin 1.8.21 Gradle 8.0.2 kotlinCompilerExtensionVersion 1.4.7