https://kotlinlang.org logo
#compose
Title
# compose
w

why

02/25/2021, 4:20 PM
Hi I would love to know if the following dependencies are necessary for a pure Jetpack Compose project :
Copy code
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'
t

Timo Drick

02/25/2021, 4:23 PM
no they are not necessary. You just need: "androidx.activityactivity compose1.3.0-alpha03" And than just the libs from compose you are using.
💯 1
w

why

02/25/2021, 4:24 PM
Thanks for your input 👍
t

Timo Drick

02/25/2021, 4:24 PM
Than you have to use this code for Activity because the AppCompatActivity is not available:
Copy code
class MainActivity: ComponentActivity()
👍 2
w

why

02/25/2021, 4:25 PM
yes I got it thanks again 🙂
t

Timo Drick

02/25/2021, 4:28 PM
It saves apk size when you not using the appcompat stuff. In my app i am able to get an Apk size < 2mb. In the beginning of compose it was < 1mb but compose and also my app increased in size.
l

Louis Pullen-Freilich [G]

02/25/2021, 4:45 PM
This is most likely because Compose currently has a dependency on appcompat and fragments - in the next release this will be removed so it should be a lot smaller
a

Adam Powell

02/25/2021, 5:05 PM
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.
last I checked when these are stripped out, small apps post-r8 shrinking still have classes.dex files < 1MB. There's a lot in appcompat that r8 can't prove it can remove safely.
c

Colton Idle

02/25/2021, 7:35 PM
OOh. So in a pure compose app we can remove appcompat dependency completely?
👌 1
a

Adam Powell

02/25/2021, 8:04 PM