Android-only components
Compose Multiplatform builds on top of Jetpack Compose. Most of Compose Multiplatform's functionality is available for all platforms. However, there are some APIs and libraries that you can use only in the Android target. This is either because they are Android-specific, or because they haven't been ported to other platforms yet. This page summarizes these parts of the Compose Multiplatform API.
Android-only API
The Android-only API is Android-specific and isn't available on other platforms. This is because other platforms don't need certain concepts that Android uses. The API usually uses classes from the android.*
package or configures Android-specific behavior. Here are some examples of parts of the Android-only API:
android.context.Context
classLocalContext
andLocalConfiguration
variablesandroid.graphics.BitmapFactory
andandroid.graphics.Bitmap
classesImageBitmap.asAndroidBitmap()
functionandroid.app.Activity
classandroid.app.Activity.setContent()
functionComposeView
classLocalView
variableModifier.pointerInteropFilter()
functionHilt dependency injection library
Usually, there isn't a strong reason to commonize parts of an API like this, so it's best to keep it in androidMain
only.
API with Android classes in their signatures
There are parts of the API in Compose Multiplatform that use android.*
, androidx.*
(excluding androidx.compose.*
) in their signatures, but their behavior is applicable for other platforms as well:
Resource management:
stringResource
,animatedVectorResource
,Font
, and*.R
class for resource management. For more information, see Images and resources.Navigation. For more information, see Navigation and routing.
ViewModel
class.Paging library.
ConstraintLayout
layout.Maps library.
Preview tool. (Desktop support).
WebView
class.Other Jetpack Compose libraries that haven't been ported to Compose Multiplatform.
They may be ported to commonMain
in the future, depending on complexity and demand.
APIs that are often used when developing applications, such as permissions, devices (Bluetooth, GPS, Camera), and IO (network, files, databases), are out of the scope of Compose Multiplatform.
API without Android classes in their signatures
Some parts of the API can be available only for the Android target, even if their signatures don't contain android.*
or androidx.*
classes, and the API is applicable to other platforms. The reason behind this is usually that the implementation uses many platform specifics and it takes time to write other implementations for other platforms.
Normally, parts of the API like this are ported to Compose Multiplatform after they are introduced in Jetpack Compose for the Android target.
In Compose Multiplatform 1.7.1, the following parts of the API are not available in commonMain
:
Modifier.imeNestedScroll()
functionModifier.systemGestureExclusion()
functionModifier.magnifier()
functionLocalOverscrollConfiguration
variablematerial3-adaptive library
material3-window-size-class library
Request to port Android API
For each API that can be ported from Android, there is an open issue in the Compose Multiplatform YouTrack. If you see that an API can be ported from Android and commonized, and there is no existing issue for it, create one.