3 Replies

For manual instrumentation, you include the mobile agent into the application at development time. The additional classes and methods contributed by the mobile agent is accounted for at application build time. If the DEX file exceeds the method count limit, whether it's due to the mobile agent or not, you need to turn your application into a multi-dex application.

For auto instrumentation, we insert the mobile agent into the primary DEX file if it's not already present (via manual instrumentation). This is where we need room for about 1300 (this number changes from time to time) methods. If the primary DEX file is too full to accommodate the mobile agent, we attempt to move some classes and methods out into another DEX file if it's a multi-dex application. We call this DEX splitting.

Some applications may experience a runtime problem (a crash due to class not found) on Android older than Lollipop after DEX splitting due to a DEX classloader problem, which is addressed on Android Lollipop and later. To avoid this problem (and also the too many string constant problem), keep the primary DEX small (to avoid DEX splitting) by applying the --minimal-main-dex option at application build time.

Thanks for the guide. I tried the configuration from the fist entry in the FAQ. It still does not work. I put both DTXMaxDexMethods=n DTXMultidexMoveMethodCount=m to the properties file, and no matter how I change the m and n, I got same error message.

I got the same problem as well. The client it is using multi-dex. However, the primary dex file has more than 64000 methods, and the second dex file has less than 4000 methods. When we do the auto-instrument. We got the "too many method" error. Any idea on how to more some of the methods on the primary dex file into the second one?

The --minimal-main-dex option only works for the DEX compiler DX. Android already started to replacing DX with the new DEX compiler D8.

The Android auto-instrumentor is capable of modifying the main DEX file correctly and therefore you don't have to use the --minimal-main-dex option. In some cases it can be possible, that the auto-instrumentor needs some fine-tuning. You can find all relevant information in the documentation.

Answer by
Mike T.·
Aug 22, 2016 at 01:12 AM

These were the values that worked for me.

DTXMaxDexMethods=65000

DTXMultidexMoveMethodCount=2549

+ the debug line so I can see
what is going on

cpwrUEM_logging.level=debug

Sometimes I set to 3,000 so try a couple of combinations.

DTXMultidexMoveMethodCount=3000

It does not always work but it has definitely worked for me with a couple of customers.

The properties DTXMaxDexMethods and DTXMultidexMoveMethodCount are not used anymore. For the 7.1.x and 7.2.x auto-instrumentor you have to use different properties. You find more details on this documentation page.

Dynatrace also works on a new auto-instrumentor that does not require fine-tuning for multidex applications. The new auto-instrumentor was announced in this blog post.

Without further information about your app, I can't recommend a value. You can create a support ticket and upload the debug logs of the auto-instrumentor. Then the support team will help you to find out suitable values.

can i set like this (agentProperties 'DTXSecondaryDexLimit=64000') for the dex?