realm-java: RealmTransformer not executing on with AGP 7.2.0/1
How frequently does the bug occur?
All the time
Description
Android Studio just updated their stable IDE version. I’m using the recommended Gradle tooling version that came with the IDE update. The app compiles normally, but crashes at runtime - and according to the error it seems fairly clear that the Realm plugin didn’t work as expected. Let me know if you need further information.
Stacktrace & log output
java.lang.ExceptionInInitializerError: RealmTransformer doesn't seem to be applied. Please update the project configuration to use the Realm Gradle plugin. See https://docs.mongodb.com/realm/sdk/android/install/#customize-dependecies-defined-by-the-realm-gradle-plugin
at io.realm.RealmConfiguration.<clinit>(RealmConfiguration.java:80)
at io.realm.RealmConfiguration.access$000(RealmConfiguration.java:68)
at io.realm.RealmConfiguration$Builder.initializeBuilder(RealmConfiguration.java:552)
at io.realm.RealmConfiguration$Builder.<init>(RealmConfiguration.java:538)
at io.realm.Realm.initializeRealm(Realm.java:320)
at io.realm.Realm.init(Realm.java:261)
at com.patreon.android.data.manager.RealmManager.initialize(RealmManager.java:55)
### Can you reproduce the bug?
Yes, always
### Reproduction Steps
_No response_
### Version
10.10.1
### What SDK flavour are you using?
Local Database only
### Are you using encryption?
No, not using encryption
### Platform OS and version(s)
all
### Build environment
Android Studio version: Android Studio Chipmunk | 2021.2.1
Build #AI-212.5712.43.2112.8512546, built on April 28, 2022
Gradle : gradle-7.3.3-all
Realm: 10.10.1
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 36
- Comments: 51 (13 by maintainers)
Some updates regarding the issue:
Using
hilt
gradle plugin beyond version 2.38 can cause theRealmTransformer
to not trigger, this might be caused by the fact thathilt
strated using the new ASM Transformer API (which will be the only Transformer supported from AGP 8.0 onwoard).Using @PVGH19 sample one can use
com.google.dagger:hilt-android-gradle-plugin:2.38
with AGP7.2.1
and it still works. Another work around is to keep using AGP 7.1.3 until we finish the process of rewriting the transformer using ASM (instead of Javassist currently).We will post here once we completed the re-write of the trasnformer.
Friendly ping, this issue has been open since May, is there a timeline when we can expect it to be resolved? This is currently blocking our migration of other libraries, which requires AGP minimum version of 7.2
Got the same problem, I’ve also tried a clean build without any success
I noticed something strange:
All works fine until Firebase Performance Monitoring (
com.google.firebase:firebase-perf
) is added. Then the error shows.Thanks @PVGH19 I’m able to reproduce the issue. I’ll have a look.
I get same results when I update AGP from 7.1.3 to 7.2.0. I’m sticking with 7.1.3 until this gets fixed
Sadly I can’t do this because Kotlin requires a certain minimum version of Hilt, and
2.38
is more than a year old, I believe it supports version of Kotlin around 1.5 which is also pretty old at this point.Today I updated all libs and tools and this crash isn’t happening anymore for me.
Gradle plugin 7.2.2 Dagger 2.43.2 Realm 10.11.1
Edit: Confirmed! https://issuetracker.google.com/issues/232438924
@Jeff11 @cmelchior I’ve added the sample project here: https://github.com/PVGH19/RealmAndDagger
Initially, it should run correctly. As soon as we change android.application version to 7.2.1 you should see the RealmTransformer crash.
@cmelchior It worked after upgrading without any issues.
Hi @PriyaSindkar. Thanks for the observation. We are in the process of migrating to the new API in #7714.
@PVGH19 Yes, that is possible. You can see how here:
https://www.mongodb.com/docs/realm-legacy/docs/java/latest/index.html#how-do-i-customize-dependecies-defined-by-the-realm-gradle-plugin
I have the same problem (not working in 7.2, working in 7.1.3 I’m not using HILT and, looking at the dependency tree, no library is using it either
going back to 7.1.3 worked for me as well.
Clean build also has the same result. It compiles just fine, but crashes at runtime. I’ll try Realm’s sample for comparison.