Home > Software engineering >  ComponentActivity can only be called from within the same library group prefix
ComponentActivity can only be called from within the same library group prefix

Time:03-19

I have a working simple Android app with MainActivity of AppCompatActivity. I changed to ComponentActivity and it generates the following warning.

ComponentActivity can only be called from within the same library group prefix (referenced groupId=androidx.core with prefix androidx from groupId=Compose play)

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            MessageCard(Message("Hello", "J C"))
        }
    }
}

But the app still compiles and runs normally. Is there any way to resolve this other than @SuppressLint("RestrictedApi")? Thanks

CodePudding user response:

You've imported the wrong ComponentActivity. Make sure you are importing androidx.activity.ComponentActivity

  • Related