Colton Idle

    Colton Idle

    10 months ago
    The live literals feature and @Preview annotation shown at AndroidDevSummit gets me excited to use that stuff, but I basically only use composable in a separate library. Was there an issuetracker for supporting @Preview in library modules that we could star? (I tried a quick search and no luck)
    Albert Chang

    Albert Chang

    10 months ago
    Are you talking about the preview in the IDE or the "deploy to device" feature? Preview should work out of the box in library modules and "deploy to device" works if you manually add a run configuration.
    n

    nitrog42

    10 months ago
    yeah actually it’s was in AS since the begin of the compose release, wasn’t it ?
    I did observe live change in emulator and it’s always nice to see, but you have to change an existing value (dp, string), adding or removing any line of code will break it until next deploy
    Colton Idle

    Colton Idle

    10 months ago
    Really? Let me try again. I swear it didn't work a few months ago.
    I must be doing something wrong...
    I'm on latest compose, latest everything really. lol
    Here is the dep I added
    implementation("androidx.compose.ui:ui-tooling-preview:1.1.0-beta01")
    Albert Chang

    Albert Chang

    10 months ago
    When you see this you should click the red circle in the top right and see what the error is. Also note that you need the latest versions of
    androidx.savedstate:savedstate
    and
    androidx.lifecycle:lifecycle-viewmodel
    as dependencies. These are already transitive dependencies of
    androidx.activity:activity
    but if you module doesn't depend on androidx.activity you may need to declare these manually (
    debugImplementation
    should be enough).
    Colton Idle

    Colton Idle

    10 months ago
    Hm. Let me give it a whirl now.
    Alright. I started fresh again. I have this
    Alt enter gives me this
    I select ui tooling prev
    It added this
    Red
    @Preview
    went away
    Sync and rebuild
    Added implementation("androidx.activity:activity:1.4.0"), rebuilt, same issue
    Colton Idle

    Colton Idle

    10 months ago
    I do have ui tooling?
    oh snap. ui-tooling and ui-tooling preview are different. shit.
    That was it. It works. Albert to the rescue... again. Cheers
    I suppose both could just be debugImplementation right?
    debugImplementation("androidx.compose.ui:ui-tooling-preview:1.1.0-beta01")
    debugImplementation("androidx.compose.ui:ui-tooling:1.1.0-beta01")
    Hopefully they can improve the experience. Thanks again albert
    Albert Chang

    Albert Chang

    10 months ago
    As the message I posted above said
    androidx.compose.ui:ui-tooling-preview
    must be
    implementation
    or the compilation of release build won’t succeed.
    Colton Idle

    Colton Idle

    10 months ago
    If anyone stumbles upon this thread. I had to add
    implementation("androidx.activity:activity:1.4.0")
    too. If I remove it, it stops working.
    Albert Chang

    Albert Chang

    10 months ago
    You can make it a
    debugImplementation
    . Or alternatively:
    debugImplementation("androidx.savedstate:savedstate:1.1.0")
    debugImplementation("androidx.lifecycle:lifecycle-viewmodel:2.4.0")
    Colton Idle

    Colton Idle

    10 months ago
    AH okay. I guess I misunderstood. So I can have debug of activity, but ui-tooling and preview need to be implementation? Do I have it right now?
    Albert Chang

    Albert Chang

    10 months ago
    users now have the option to add ui-tooling-preview as
    an implementation API and ui-tooling as debugImplementation
    ui-tooling
    depends on
    ui-tooling-preview
    so if you add
    ui-tooling
    as
    implementation
    you don’t need to explicitly declare
    ui-tooling-preview
    . However
    ui-tooling-preview
    is needed for compilation so if
    ui-tooling
    is
    debugImplementation
    you need to add
    ui-tooling-preview
    as
    implementation
    .