FunnySaltyFish
11/17/2024, 12:01 PMAppCompatActivity
in Kotlin 2.0.21. Here's my setup:
// commonMain
expect abstract class KMPActivityexpect open class BaseActivity() : KMPActivity
expect class LoginActivity: BaseActivity// androidMain
actual abstract class KMPActivity: AppCompatActivity() // This causes compilation erroractual open class BaseActivity : KMPActivity()
actual class LoginActivity : BaseActivity()
The compiler error is:
'actual class LoginActivity : BaseActivity' has no corresponding members for expected class members:
field mFragments: FragmentController!
The following declaration is incompatible because actualization to Java field is prohibited:
field mFragments: FragmentController!
field mFragmentLifecycleRegistry: LifecycleRegistry!
The following declaration is incompatible because actualization to Java field is prohibited:
field mFragmentLifecycleRegistry: LifecycleRegistry!
field mCreated: Boolean
The following declaration is incompatible because actualization to Java field is prohibited:
field mCreated: Boolean
field mResumed: Boolean
The following declaration is incompatible because actualization to Java field is prohibited:
field mResumed: Boolean
field mStopped: Boolean
The following declaration is incompatible because actualization to Java field is prohibited:
field mStopped: Boolean
Interestingly, if I change AppCompatActivity
to ComponentActivity
, it compiles fine! 🤔
I found a related issue in YouTrack: Here
Has anyone found a clean way to use AppCompatActivity
in a KMP project with Kotlin 2.0+? I need the AppCompat features but can't figure out how to properly actualize the Activity class. Any suggestions or workarounds would be greatly appreciated! 🙏
Full code: Code