Why are classes from the legacy Android Support Libraries in my APK?

88 views Asked by At

I've created a new Android app using Android Studio's wizard. It's a Compose-based app, "modern" style, only Jetpack. I only create the project and run a build with ./gradlew :app:assembleDebug.

When I use apkanalyzer on the generated APK, I see classes from android.support.v4 library, which is pretty old and has been replaced by Jetpack long time ago.

$ cd app/build/outputs/apk/debug/
$ apkanalyzer dex packages app/build/outputs/apk/debug/app-debug.apk --defined-only | grep '^C' | grep 'android.support'
C d 6   8   628 android.support.v4.os.IResultReceiver$Stub
C d 7   7   628 android.support.v4.os.ResultReceiver
C d 5   5   308 android.support.v4.os.ResultReceiver$1
C d 4   4   434 android.support.v4.os.IResultReceiver$Stub$Proxy
C d 3   3   197 android.support.v4.os.IResultReceiver$Default
C d 1   2   91  android.support.v4.os.IResultReceiver
C d 2   2   229 android.support.v4.os.ResultReceiver$MyRunnable
C d 2   2   228 android.support.v4.os.ResultReceiver$MyResultReceiver
C d 6   10  808 android.support.v4.app.INotificationSideChannel$Stub
C d 6   6   829 android.support.v4.app.INotificationSideChannel$Stub$Proxy
C d 5   5   285 android.support.v4.app.INotificationSideChannel$Default
C d 3   3   107 android.support.v4.app.INotificationSideChannel
C d 3   3   178 android.support.v4.app.RemoteActionCompatParcelizer
C d 3   3   178 android.support.v4.graphics.drawable.IconCompatParcelizer

Why's that?

1

There are 1 answers

0
ianhanniballake On BEST ANSWER

Those classes that extend Parcelable, like all of those classes, are capable of being sent across processes. Parcelable encodes the entire class name as part of its encoding, so the full class name, including the package, becomes part of the public API.

Therefore to support communicating between apps built with the Support Library and apps built with their AndroidX equivalents, no Parcelable class could have its package name changed. That's why these classes still appear in your APK.