我尝试构建以下项目,但收到一些错误:https://github.com/bufferapp/android-clean-architecture-mvi-boilerplate
1-Kotlin编译器错误:
error: no interface expected here
public class ViewModelFactory extends android.arch.lifecycle.ViewModelProvider.Factory {
ViewModelFactory如下:
@Singleton
open class ViewModelFactory : ViewModelProvider.Factory {
private val creators: Map<Class<out ViewModel>, Provider<ViewModel>>
@Inject constructor(creators: Map<Class<out ViewModel>,
@JvmSuppressWildcards Provider<ViewModel>>) {
this.creators = creators
}
override fun <T : ViewModel> create(modelClass: Class<T>): T {
var creator: Provider<out ViewModel>? = creators[modelClass]
if (creator == null) {
for ((key, value) in creators) {
if (modelClass.isAssignableFrom(key)) {
creator = value
break
}
}
}
if (creator == null) {
throw IllegalArgumentException("unknown model class " + modelClass)
}
try {
return creator.get() as T
} catch (e: Exception) {
throw RuntimeException(e)
}
}
}
2-Kotlin编译器错误:
error: @Binds methods must have only one parameter whose type is assignable to the return type
public abstract android.arch.lifecycle.ViewModelProvider.Factory bindViewModelFactory(@org.jetbrains.annotations.NotNull()
它发生在以下课程上:
@Module
abstract class PresentationModule {
@Binds
@IntoMap
@ViewModelKey(BrowseBufferoosViewModel::class)
abstract fun bindBrowseBufferoosViewModel(viewModel: BrowseBufferoosViewModel): ViewModel
@Binds
abstract fun bindViewModelFactory(factory: ViewModelFactory): ViewModelProvider.Factory
}
有人可以建议我如何解决错误吗?