compose-multiplatform: Failed to resolve: androidx.activity:activity-ktx:1.3.0-alpha01

Trying to build the imageViewer example but gradle sync shows this error:

> Could not find androidx.activity:activity-ktx:1.3.0-alpha01.
     Required by:
         project :android > org.jetbrains.compose.ui:ui-android-debug:0.3.0-build149

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 19 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks @jimgoog , I will apply it to the TodoApp

Ok, sounds like imageviewer and todoapp have been fixed now.

@Shabinder Decompose is already updated, please checkout version 0.1.8.

Oops, I’ll leave this open until we merge an upgraded gradle configuration into the sample.

Managed to compile by copy-pasting the moved implementation of setContent:

fun ComponentActivity.setContent(
    parent: CompositionContext? = null,
    content: @Composable () -> Unit
) {
    val existingComposeView = window.decorView
        .findViewById<ViewGroup>(android.R.id.content)
        .getChildAt(0) as? ComposeView

    if (existingComposeView != null) with(existingComposeView) {
        setParentCompositionContext(parent)
        setContent(content)
    } else ComposeView(this).apply {
        // Set content and parent **before** setContentView
        // to have ComposeView create the composition on attach
        setParentCompositionContext(parent)
        setContent(content)
        setContentView(this, DefaultLayoutParams)
    }
}

private val DefaultLayoutParams = ViewGroup.LayoutParams(
    ViewGroup.LayoutParams.WRAP_CONTENT,
    ViewGroup.LayoutParams.WRAP_CONTENT
)

@CarsonRedeye,

I managed to build it with Kotlin 1.4.30 and JB Compose 0.3.0-build152, but some additional configuration was necessary.

First, I needed to add a snapshot repository containing activity-compose artifacts:

allprojects {
    repositories {
        // AndroidX snapshots (https://androidx.dev/):
        maven { url = uri("https://androidx.dev/snapshots/builds/7134056/artifacts/repository/") }
    }
}

So that I could add androidx.activity:activity-compose:1.3.0-SNAPSHOT dependency.

However, activity-compose uses other non-existing dependencies, which I couldn’t quickly find in the androidx.dev snapshots (there’s no easy search).

In my case, this worked:

val androidMain by getting {
    dependencies {
        api("androidx.activity:activity-compose:1.3.0-SNAPSHOT") {
            isTransitive = false
        }
    }
}

But I guess you might need to browse through the other snapshots to find the missing artifacts, depending on the specific case.

This workaround is probably necessary until androidx.activity:activity-compose:1.3.0-alpha01 is released.

Seems that androidx.activity:activity-ktx:1.3.0-alpha01 is no longer required with 0.3.0-build150.

Now, however, ComponentActivity.setContent() (from package androidx.compose.ui.platform) no longer exists. According to deprecation message from 0.3.0-build149, it has been moved to the androidx.activity:activity-compose artifact (which also cannot be resolved). I assume this artifact has only been introduced in AndroidX Activity version 1.3.0-alpha01?