LouisCAD / Splitties

A collection of hand-crafted extensions for your Kotlin projects.
https://splitties.louiscad.com
Apache License 2.0
2.53k stars 159 forks source link

IDE preview requires full Gradle buid to work ? #211

Closed christopheblin closed 5 years ago

christopheblin commented 5 years ago

When I use splitties.views.dsl.idepreview.UiPreView in a layout file, is it normal that it displays the correct preview only after a project build (i.e modifications on the code are not displayed until I rebuild) ?

If so, what is the point to have a preview (i.e it is so slooooooooooooow to perform a Gradle build in Android Studio) ? Or maybe there is a workaround to just build the Ui class or something like that ?

LouisCAD commented 5 years ago

Android Studio unfortunately suggests to do a full build, but it's not actually required.

Running the compileDebugKotlin gradle task is enough (and the mergeDebugJavaResource task in case you encounter an error like that one: https://github.com/LouisCAD/Splitties/issues/210).

If you don't have non incremental kapt dependencies, or better yet, no kapt dependencies at all in the module where you have your UI, build should be very fast, unless you have an insanely massive codebase or other things that slow the build down.

Incremental compilation shows its benefits starting from the second build following major changes like dependency additions or updates.

In my case, I have a module with UI only, and running these tasks range from 1 to 10 seconds.

christopheblin commented 5 years ago

Ok, thanks for sharing your tips, I'll try to move all my Uis in a dedicated module to see how fast it can be (or yet better, to have "real" modules in my app instead of a single one)

Currently, just changing a boolean from true to false (or the opposite), it takes 35s to build my project and about 12s for compileDebugKotlin so it is definitively better...