问题
During my profile report of assembleDebug gradle task I discovered two realm related gradle sub-tasks which takes quite big amount of time:
assembleDebug - 1m21.44s
- transformClassesWithRealmOptionalAPITransformerForDebug - 22.386s
- transformClassesWithRealmTransformerForIdeDebug - 10.062s
Questions:
- what exactly those realm related gradle sub tasks do? Can I skip them at some point?
- why they took so long? (22 + 10 = 32 sec)
Update
As a workaround I am skipping task via -x script parameter
assembleDebug -x transformClassesWithRealmOptionalAPITransformerForDebug
回答1:
transformClassesWithRealmOptionalAPITransformerForDebug is created for removing RxJava related APIs since it might create troubles for some cases (cases which need reflection like https://realm.io/docs/java/latest/#jackson-databind) which doesn't have the RxJava dependency. But we found it doesn't play well in some occasions like https://github.com/realm/realm-java/issues/3033 and https://github.com/realm/realm-java/issues/3022 . So it will be disabled in the next release after v1.0.1.
transformClassesWithRealmTransformerForIdeDebug is the core part Realm relies on. Basically it replace the field access to the RealmObject with Realm accessors by bytecode manipulating. You can see this post for a bit more details. Thus, this task cannot be skipped.
PS. an issue is created to track the transformer speed improvement.
来源:https://stackoverflow.com/questions/37928953/realm-gradle-tasks