SaeHyun Kim
SaeHyun Kim

Reputation: 485

How can I check the dex count in android?

My project's gradle file is as below.

android {
    compileSdkVersion 23
    buildToolsVersion "25.0.1"

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt')
        }
    }
}

I can see DexIndexOverflowException when "Generate Signed APK" in Android Studio.

Error:Execution failed for task ':MyProject:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: 
com.android.ide.common.process.ProcessException: 
java.util.concurrent.ExecutionException: 
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

I already know this error and read the document(https://developer.android.com/studio/build/multidex.html).
Just I want to check How many dex has exceeded.

For example:

trouble writing output:
Too many field references: 99999; max is 65536.
You may try using --multi-dex option.

Please find a solution.

Upvotes: 8

Views: 8750

Answers (5)

Manolee
Manolee

Reputation: 21

Take a look at this. I was searching for the same and found my answer here. Basicly, you have to generate the APK of your project and then go to Build->Analyze APK and at the rasults click on classes.dex, then, below you will see exactly how many methods are defined and referenced by the project.

Upvotes: 1

UnknownStack
UnknownStack

Reputation: 1360

I modified dx.jar source to show method count.

https://github.com/b1uec0in/dx

Output sample

string ID count: 91,857
type ID count: 12,636
proto ID count: 18,417
field ID count: 72,011 (max:65535 +6476)
method ID count: 81,181 (max:65535 +15646)

replace your dx.jar with this dx.jar.

Upvotes: 0

Karakuri
Karakuri

Reputation: 38605

Android Studio has an APK analyzer that shows this information, no gradle plugins required.

Upvotes: 7

sivaBE35
sivaBE35

Reputation: 1891

use this plugin to get the number of method references in your APK on every build.

dexcount

Upvotes: 1

ashkhn
ashkhn

Reputation: 1620

Android studio has a plugin called Android Methods Count which will show the number of methods for each of your dependencies.

There's also a cli tool available with more options at https://github.com/mihaip/dex-method-counts

Upvotes: 0

Related Questions