Join us for ⁠#Android11: The Beta Launch Show on June 3!

Compose

Latest Update Current Release
May 14, 2020 0.1.0-dev11

Declaring dependencies

To add a dependency on Compose, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

dependencies {
    implementation "androidx.compose:compose-runtime:0.1.0-dev11"
}

android {
    buildFeatures {
        compose true
    }

    composeOptions {
        kotlinCompilerVersion "1.3.70-dev-withExperimentalGoogleExtensions-20200424"
        kotlinCompilerExtensionVersion "0.1.0-dev11"
    }
}

For more information about dependencies, see Add build dependencies.

Feedback

Your feedback helps make Jetpack better. Please let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.

Create a new issue

See the Issue Tracker documentation for more information.

Version 0.1.0-dev

Version 0.1.0-dev11

May 14, 2020

androidx.compose:compose-compiler:0.1.0-dev11 and androidx.compose:compose-runtime:0.1.0-dev11 are released. Version 0.1.0-dev11 contains these commits.

API Changes

  • Added an adapter for Flow. Example of the usage:

    val value by flow.collectAsState()
    

    (If2198, b/153375923)

Bug Fixes

  • Updated higher level compose APIs that expose a Canvas to expose CanvasScope instead. This removes the need for consumers to maintain their own Paint objects. For consumers that still require access to a Canvas they can use the drawCanvas extension method which provides a callback to issue drawing commands with the underlying Canvas. (I80afd)
  • WithConstraints trailing lambda API has been changed. Now instead of two params it has a receiver scope which in addition to constraints and layoutDirection provides minWidth, maxWidth, minHeight, and maxHeight properties in Dp (I91b9a, b/149979702)
  • Added symmetric padding modifier. (I39840)

Version 0.1.0-dev10

April 29, 2020

androidx.compose:compose-compiler:0.1.0-dev10 and androidx.compose:compose-runtime:0.1.0-dev10 are released. Version 0.1.0-dev10 contains these commits.

New Features

  • Rebased on a newer version of the Kotlin compiler's IR backend, which means that many of the features that previously didn't work with the IR backend (like non-composable coroutines!) should now work! This should mean you run into fewer cryptic "Backend Internal error" messages, and don't need to work as hard to separate your code into IR and non-IR modules. However, the IR backend is still experimental and still has some bugs (just far fewer of them) so try things out and enjoy but keep in mind it's still a work in progress.

Version 0.1.0-dev09

April 15, 2020

androidx.compose:compose-compiler:0.1.0-dev09 and androidx.compose:compose-runtime:0.1.0-dev09 are released. Version 0.1.0-dev09 contains these commits.

API Changes

  • [Mutable]State property delegate operators moved to extensions to support Kotlin 1.4 property delegate optimizations. Callers must add imports to continue using by state { ... } or by mutableStateOf(...). (I5312c)

Bug Fixes

  • Updated wrapContentWidth and wrapContentHeight to expect vertical or horizontal Alignment rather than any Alignment. The gravity modifier was updated to accept vertical or horizontal Alignment. Row, Column, and Stack were updated to support custom continuous Alignments. (Ib0728)
  • ui-text module was renamed to ui-text-core (I57dec)
  • Improved DrawModifier API ((Ibaced, b/152919067)):
    • Made the receiver scope for draw() ContentDrawScope
    • Removed all parameters on draw()
    • DrawScope has same interface as former CanvasScope
    • ContentDrawScope has drawContent() method
  • ColoredRect has been deprecated. Use Box(Modifier.preferredSize(width, height).drawBackground(color)) instead. (I499fa, b/152753731)

Version 0.1.0-dev08

April 1, 2020

androidx.compose:compose-compiler:0.1.0-dev08 and androidx.compose:compose-runtime:0.1.0-dev08 are released. Version 0.1.0-dev08 contains these commits.

Bug Fixes

  • Replaced Modifier plus operator with factory extension functions (I225e4)
  • RowScope and ColumnScope members are now accessible outside Row and Column. (I3a641)

Version 0.1.0-dev07

March 18, 2020

androidx.compose:compose-compiler:0.1.0-dev07 and androidx.compose:compose-runtime:0.1.0-dev07 are released. Version 0.1.0-dev07 contains these commits.

API Changes

  • androidx.compose.ViewComposer has been moved to androidx.ui.node.UiComposer. (Idef00)
  • androidx.compose.Emittable has been removed. It was redundant with ComponentNode. (Idef00)
  • `androidx.compose.ViewAdapters has been removed. They are no longer a supported use case. (Idef00)
  • Compose.composeInto has been deprecated. Use setContent or setViewContent instead. (Idef00)
  • Compose.disposeComposition has been deprecated. Use the dispose method on the Composition returned by setContent instead. (Idef00)
  • androidx.compose.Compose.subcomposeInto has moved to androidx.ui.core.subcomposeInto. (Idef00)
  • ComponentNode#emitInsertAt has been renamed to ComponentNode#insertAt. (Idef00)
  • ComponentNode#emitRemoveAt has been renamed to ComponentNode#removeAt. (Idef00)
  • ComponentNode#emitMode has been renamed to ComponentNode#move. (Idef00)

Bug Fixes

  • Renamed LayoutFlexible to LayoutWeight. Renamed tight parameter to fill. (If4738)
  • WithConstraints got LayoutDirection parameter (I6d6f7)

Version 0.1.0-dev06

March 4, 2020

androidx.compose:compose-compiler:0.1.0-dev06 and androidx.compose:compose-runtime:0.1.0-dev06 are released. Version 0.1.0-dev06 contains these commits.

New Features

  • Updated the ComposeFlags.COMPOSER_PARAM flag to be true, which will change the code generation strategy for the compose plugin. At a high level, this causes @Composable functions to be generated with an additional synthetic parameter, which is passed through to subsequent @Composable calls in order for the runtime to properly manage execution. This is a significant binary breaking change, however, should preserve source-level compatibility in all sanctioned usage of compose. (aosp/1226314)

Version 0.1.0-dev05

February 19, 2020

androidx.compose:compose-compiler:0.1.0-dev05 and androidx.compose:compose-runtime:0.1.0-dev05 are released. Version 0.1.0-dev05 contains these commits.

API Changes

  • Breaking changes to the ambients API. See log and Ambient<T> documentation for details (I4c7ee, b/143769776)

Bug Fixes

  • Replaced ButtonStyle with distinct functions and removed text (string) overload. See updated samples for usage information. (If63ab, b/146478620, b/146482131)

Version 0.1.0-dev04

January 29, 2020

androidx.compose:compose-compiler:0.1.0-dev04 and androidx.compose:compose-runtime:0.1.0-dev04 are released. The commits included in this version can be found here.

API Changes

  • Added areEquivalent callback to MutableState (Ic2ef8)
  • Removed Component and refactor top-level composition APIs (I1f22e)
  • Transform composable calls with composer param (I1691e)
  • Remove Composition classes in favor of Composer base class (Ieadbf)
  • Mark State<T> and MutableState<T> as stable types (b/146557624)
  • Add currentComposerIntrinsic and tests to ensure correct param passing (I133f0)
  • Made ModelObserver single-threaded. (Ica33d)
  • Correctly generate groups around inline composable calls (Ibf739)
  • Remove unused EffectsDsl annotation (Ibe81d)
  • Added a @Stable annotation. Marked Modifier as stable. (Iacba7)
  • Introduced MutableState, State, mutableStateOf APIs (I98291)
  • Refactored effects to @Composable (Ie2686)
  • Improved performance of ObserverMap and ModelObserver. (Ieb9b6)
  • Changed read observations to allow observing non-ComponentNodes. (Ia4d93)