Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to resolve: androidx.activity:activity-ktx:1.3.0-alpha01 #354

Closed
Chozzle opened this issue Feb 7, 2021 · 19 comments
Closed

Failed to resolve: androidx.activity:activity-ktx:1.3.0-alpha01 #354

Chozzle opened this issue Feb 7, 2021 · 19 comments

Comments

@Chozzle
Copy link

Chozzle commented Feb 7, 2021

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
@jimgoog
Copy link
Collaborator

jimgoog commented Feb 7, 2021

Yeah, sorry about that - it's a known issue we discovered a couple of days ago.

@olonho @igordmn This was fixed in master (https://android-review.googlesource.com/c/platform/frameworks/support/+/1576432) so I think if we can push out another build rebased on master, this should go away.

Or alternatively, I think this missing artifact is intended to be published on Wednesday, which should hopefully also resolve this issue.

So a couple of fixes are already in flight, and it's a race to see which fix gets published first.

Sorry for the inconvenience. It sucks when examples don't build :(.

@jimgoog
Copy link
Collaborator

jimgoog commented Feb 7, 2021

@Chozzle As a temporary workaround, I think downgrading from 0.3.0-build149 to 0.3.0-build148 and downgrading Kotlin to 1.4.21-2 would unblock you temporarily, if you really need to get the sample working. But know a fix is in the works and one way or another should presumably be fixed in a couple of days.

@jimgoog
Copy link
Collaborator

jimgoog commented Feb 7, 2021

@Chozzle Or it looks like 0.3.0-build150 just got published. There are a few things that got deprecated/moved, so some clean up is required if you upgrade, but that should also work.

@CarsonRedeye
Copy link

No problem I can wait for the fix. It's just for my library compose-macos-theme. It appears that the problem persists with build 150 though

@sczerwinski
Copy link

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?

@CarsonRedeye
Copy link

That make sense. I wasn't able to build the Android app in my example due to this

@sczerwinski
Copy link

@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.

@arkivanov
Copy link
Contributor

Looks like androidx.activity:activity-compose:1.3.0-alpha01 is released. But I can't compile the TodoApp example with Kotlin 1.4.30 and Compose 0.3.0-build152. Getting the following error:

> Task :android:mergeDebugResources

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class androidx.compose.animation.core.Animatable found in modules jetified-animation-core-1.0.0-alpha12-runtime.jar (androidx.compose.animation:animation-core:1.0.0-alpha12) and jetified-animation-core-debug-runtime.jar (org.jetbrains.compose.animation:animation-core-android-debug:0.3.0-build152)
  Duplicate class androidx.compose.animation.core.Animatable$runAnimation$2 found in modules jetified-animation-core-1.0.0-alpha12-runtime.jar (androidx.compose.animation:animation-core:1.0.0-alpha12) and jetified-animation-core-debug-runtime.jar (org.jetbrains.compose.animation:animation-core-android-debug:0.3.0-build152)
  Duplicate class androidx.compose.animation.core.Animatable$runAnimation$2$1 found in modules jetified-animation-core-1.0.0-alpha12-runtime.jar (androidx.compose.animation:animation-core:1.0.0-alpha12) and jetified-animation-core-debug-runtime.jar (org.jetbrains.compose.animation:animation-core-android-debug:0.3.0-build152)
  Duplicate class androidx.compose.animation.core.Animatable$snapTo$2 found in modules jetified-animation-core-1.0.0-alpha12-runtime.jar (androidx.compose.animation:animation-core:1.0.0-alpha12) and jetified-animation-core-debug-runtime.jar (org.jetbrains.compose.animation:animation-core-android-debug:0.3.0-build152)
  Duplicate class androidx.compose.animation.core.Animatable$stop$2 found in modules jetified-animation-core-1.0.0-alpha12-runtime.jar (androidx.compose.animation:animation-core:1.0.0-alpha12) and jetified-animation-core-debug-runtime.jar (org.jetbrains.compose.animation:animation-core-android-debug:0.3.0-build152)
  Duplicate class androidx.compose.animation.core.AnimatableKt found in modules jetified-animation-core-1.0.0-alpha12-runtime.jar (androidx.compose.animation:animation-core:1.0.0-alpha12) and jetified-animation-core-debug-runtime.jar (org.jetbrains.compose.animation:animation-core-android-debug:0.3.0-build152)
... And many many more similar errors

@arkivanov
Copy link
Contributor

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
)

@sczerwinski
Copy link

Looks like androidx.activity:activity-compose:1.3.0-alpha01 uses androidx.compose.runtime:runtime:1.0.0-alpha12, which defines:

@Deprecated("Renamed to CompositionContext")
typealias CompositionReference = CompositionContext

Since CompositionContext is also defined in compose-jb, using androidx.activity:activity-compose doesn't seem to be a good idea.

I think the setContent function copy-pasted by @arkivanov should also be implemented in compose-jb.

@jimgoog
Copy link
Collaborator

jimgoog commented Feb 10, 2021

Ok, finally published.

You should now be able to use activity-compose:1.3.0-alpha02, let me know if you run into any issues with that.

Please make sure you add an explicit dependency on androidx.activity:activity-compose:1.3.0-alpha02 when upgrading to this Compose version https://developer.android.com/jetpack/androidx/releases/activity#1.3.0-alpha02

@jimgoog jimgoog closed this as completed Feb 10, 2021
@jimgoog jimgoog reopened this Feb 10, 2021
@jimgoog
Copy link
Collaborator

jimgoog commented Feb 10, 2021

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

@arkivanov
Copy link
Contributor

arkivanov commented Feb 10, 2021

@jimgoog Looks like errors are still same: "Duplicate class ..."

@jimgoog
Copy link
Collaborator

jimgoog commented Feb 11, 2021

One step at a time. First step is to get imageviewer building which is done in #374

@arkivanov
Copy link
Contributor

arkivanov commented Feb 11, 2021

Thanks @jimgoog , I will apply it to the TodoApp

@Shabinder
Copy link

Shabinder commented Feb 11, 2021

Thanks @jimgoog , I will apply it to the TodoApp

Waiting for it...., decompose was throwing earlier an error:with Kotlin 1.4.30: Class 'com.arkivanov.decompose.extensions.compose.jetbrains.RouterStateComposableKt' is compiled by an unstable version of the Kotlin compiler and cannot be loaded by this compiler.

decompose gonna get updated too?

@arkivanov
Copy link
Contributor

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

@arkivanov
Copy link
Contributor

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

@jimgoog The workaround from #374 worked for the example TodoApp, submitted PR. Thanks!

@jimgoog
Copy link
Collaborator

jimgoog commented Feb 13, 2021

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

@jimgoog jimgoog closed this as completed Feb 13, 2021
MatkovIvan pushed a commit to MatkovIvan/compose-multiplatform that referenced this issue May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants