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

Can't build after updating to kotlin 1.5.21, latest androidx releases and compose 1.1.0-alpha01 #2800

Closed
ColtonIdle opened this issue Aug 4, 2021 · 2 comments

Comments

@ColtonIdle
Copy link

I typically use latest versions of everything. After compose was updated to 1.1.0-alpha01 today I updated that and kotlin to 1.5.21 and then androidx had a bunch of releases today. After updating everything I get this when I try to run. I have tried cleaning and running too with the same error.

I have not gotten a minimal repro project or anything more than this, but I figured I'd file preemptively in case the hilt team already knows that there's some kind of issue with compose/kotlin/lifecycle deps.

Class 'MyScreenViewModelFactory' is not abstract and does not implement abstract member public abstract fun <T : ViewModel> create(modelClass: Class<T>): T defined in androidx.lifecycle.ViewModelProvider.Factory
@ColtonIdle
Copy link
Author

Looks like maybe lifecycle related?

Source-breaking change: ViewModelProvider has been rewritten in Kotlin. ViewModelProvider.Factory.create method now longer allows nullable generic. (I9b9f6)

https://developer.android.com/jetpack/androidx/releases/lifecycle#2.4.0-alpha03

I don't know if that's actually the issue. Just guessing here.

@ColtonIdle
Copy link
Author

Solved! (thanks Ian Lake)

class MyScreenViewModelFactory(private val client: Client?) : ViewModelProvider.Factory {

    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
        return MyScreenViewModel(client) as T
    }
}

Just had to remove the ? after ViewModel, and then clean, and then rebuild.

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

1 participant