One Off the Slack: Death to AppCompat!

Slack user “why” asked:

Hi I would love to know if the following dependencies are necessary for a pure Jetpack Compose project :

implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0'

Timo Drick points out that they are not necessary (though in truth I suspect that Timo is referring mostly to appcompat):

no they are not necessary.

You just need: “androidx.activity:activity-compose:1.3.0-alpha03”

And than just the libs from compose you are using.

Than you have to use this code for Activity because the AppCompatActivity is not available:

class MainActivity: ComponentActivity()

In reality, Compose has transitive dependencies that pull in appcompat, but they are there mostly for compatibility purposes, as Google’s Adam Powell noted:

yeah those transitive dependencies were added for the alphas not because compose actually needs them, but because if you are using them elsewhere in your app, they need to be at least a particular version or newer for compose to not run into problems.

He also pointed to a post by Google’s Chris Banes covering the benefits of removing AppCompat, Material Design Components, etc. from your project.


Read the original thread in the kotlinlang Slack workspace. Not a member? Join that Slack workspace here!