Quick Start - Jetpack Compose - Android Developers
Quick Start - Jetpack Compose - Android Developers
For the best experience developing with Compose, download and install Android Studio
(/studio). It includes many smart editor features (/develop/ui/compose/tooling), such as new
project templates and the ability to immediately preview your Compose UI and
animations.
Follow these instructions to create a new Compose app project, set up Compose for an
existing app project, or import a sample app written in Compose.
1. If you're in the Welcome to Android Studio window, click Start a new Android
Studio project. If you already have an Android Studio project open , select File >
New > New Project from the menu bar.
2. In the Select a Project Template window, select Empty Activity and click Next.
a. Set the Name, Package name, and Save location as you normally would.
Note that, in the Language dropdown menu, Kotlin is the only available
option because Jetpack Compose works only with classes written in Kotlin.
b. In the Minimum API level dropdown menu, select API level 21 or higher.
4. Click Finish.
Now you're ready to start developing an app using Jetpack Compose. To help you get
started and learn about what you can do with the toolkit, try the Jetpack Compose
tutorial (/develop/ui/compose/tutorial).
To start using Compose, you need to first add some build configurations to your project.
Add the following definition to your app’s build.gradle file:
GroovyKotlin (#kotlin)
(#groovy)
android {
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.13"
}
}
In addition, add the Compose BOM and the subset of Compose library dependencies you
need to your dependencies from the block below:
GroovyKotlin (#kotlin)
(#groovy)
dependencies {
// UI Tests
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
Note: Jetpack Compose is shipped using a Bill of Materials (BOM), to keep the versions of all library
groups in sync. Read more about it in the Bill of Materials page (/develop/ui/compose/bom/bom).
Try Jetpack Compose sample apps
The fastest way to experiment with the capabilities of Jetpack Compose is by trying
Jetpack Compose sample apps (https://github.com/android/compose-samples) hosted on
GitHub. To import a sample app project from Android Studio, proceed as follows:
2. In the search bar near the top of the Browse Samples wizard, type "compose".
3. Select one of the Jetpack Compose sample apps from the search results and click
Next.
4. Either change the Application name and Project location or keep the default
values.
5. Click Finish.
Android Studio downloads the sample app to the path you specified and opens the
project. You can then inspect MainActivity.kt in each of the examples to see Jetpack
Compose APIs such as crossfade animation, custom components, using typography, and
displaying light and dark colors in the in-IDE preview.
To use Jetpack Compose for Wear OS, see Set up Jetpack Compose on Wear OS
(/training/wearables/compose-setup).
Content and code samples on this page are subject to the licenses described in the Content License
(/license). Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.