Kotlin Multiplatform Development 1.6.2 Help

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:

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:

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.6.2, the following parts of the API are not available in commonMain:

Request to port Android API

For each API that can be ported from Android, there is an open issue in the Compose Multiplatform repository. If you see that an API can be ported from Android and commonized, and there is no existing issue for it, create one.

Last modified: 28 November 2023