Is it possible to get a DEX method count breakdown...
# android
k
Is it possible to get a DEX method count breakdown by dependency? I have this grouping of dependencies and it's got more than 65K methods while writing very little code of my own.
Copy code
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    implementation 'androidx.core:core-ktx:1.3.2'
    implementation "androidx.fragment:fragment-ktx:1.2.5"
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.2'

    implementation "com.squareup.retrofit2:retrofit:2.9.0"
    implementation "com.squareup.retrofit2:converter-moshi:2.9.0"
    implementation "com.squareup.moshi:moshi-kotlin-codegen:1.11.0"
    kapt "com.squareup.moshi:moshi-kotlin-codegen:1.11.0"

    implementation 'com.google.dagger:hilt-android:2.29.1-alpha'
    kapt 'com.google.dagger:hilt-android-compiler:2.29.1-alpha'
    implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02'
    kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02'
Cannot fit requested classes in a single dex file (# methods: 70231 > 65536)
i
Have you tried APK Analyzer tool in Android Studio. that should help
l
You should just enable multidex, and use R8 in release mode (and check you didn't forget any proguard/R8 rules by trying your app)
k
@louiscad I've enabled mutlidex, but it feels wrong to do so. I've used this grouping of dependencies before and haven't have dex size issues. I'll have to checkout r8 rules and see if that helps. Thanks!
@Iqbal Ahmed Do you need to have a built APK to analyze? Currently the build fails because of dex size limits.
l
@kevin.cianfarini Have you updated any of these libraries in the meantime, or added another small one that might depend on bigger other libraries?
k
I've tried upgrading and downgrading multiple times. The dex size of these libraries changes by a hundred or so methods. The libraries I've fiddled with here don't really have much of an impact as far as I can tell. The only new library I'm using is Hilt. Does anyone know if that's got quite a large footprint or something?
l
This Gradle plugin might help you find out: https://github.com/KeepSafe/dexcount-gradle-plugin
k
I'll take a look at that as well. Thanks!
I have a feeling I'm somehow including two android.jar dependencies or something weird like that