Reputation: 621
Using this guide to test dialog https://developer.android.com/guide/fragments/test The bottom sample
with(launchFragment<MyDialogFragment>()) {
onFragment { fragment -> // here error
assertThat(fragment.dialog).isNotNull()
assertThat(fragment.requireDialog().isShowing).isTrue()
fragment.dismiss()
fragment.parentFragmentManager.executePendingTransactions()
assertThat(fragment.dialog).isNull()
}
}
But here it shows error
onFragment { fragment -> // error below
Type mismatch. Required: FragmentScenario.FragmentAction Found: (???) → Unit Cannot infer a type for this parameter. Please specify it explicitly
Upvotes: 2
Views: 566
Reputation: 31
The solution is to change the kotlin version in module build.gradle
.
buildscript {
ext {
...
kotlin_version = "1.5.31"
}
}
My origin kotlin version is 1.3.x, and it happened with the same error.
Then I go to github for the guide and found out that.
Upvotes: 0
Reputation: 621
Guys the solution was Kotlin version. So update Kotlin plugin in studio solves the issue
Upvotes: 1