1

There wasn't any problem when I add:

multiDexEnabled true

but I want to disable multidex.. when I make it:

multiDexEnabled false

or just deleting this line I get this error:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

I made my research everybody said that you need to make multidex true ... But I don't want to use multidex.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96

2 Answers2

3

If you don't want to use multidex just remove this whole line. Just be sure, that your app does not exceed the 65k methods limit. Otherwise, you will really need multidex, but only if your minSdk < 21. If it's >=21, than you don't need multidex at all, the runtime will handle all stuff.

If you'll encounter this exception even after removing the whole line, try to Build->Rebuild.

Yurii Kyrylchuk
  • 809
  • 7
  • 16
  • when i deleted the line error is the same. or making rebuild i got too. –  Apr 05 '18 at 20:05
  • I have really small app (minSdk 23) without multidex but it has multi class.dex. When I put minSdk 20 - app has single class.dex – resource8218 Dec 19 '18 at 12:33
2

You can disable multidex only if your project doesn't exceed either 65k methods limitation or 65k fields limitation. People seems to be unaware about the 65k fields limitation. You can hit the fields limitation if you're using huge total of resources like drawable, string id, etc.

You can use Dexcount Gradle Plugin to check if you're hitting the 65k limitation:

A Gradle plugin to report the number of method references in your APK or AAR on every build.

This helps you keep tabs on the growth of your app, with an eye to staying under the 65,536 method-reference limit, and avoiding the headache of eliminating methods or enabling multidex.

You need to check about Firebase/Google Play Service dependencies.

Don't use the combined play-services target. It brings in dozens of libraries, bloating your application. Instead, specify only the specific Google Play services APIs your app uses.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96