30787

multiDexEnabled do not work

Question:

I have a rather large android project. The project still compiles, but when I try to compile tests I get an error:

Execution failed for task ':app:dexDebugTest'. trouble writing output: Too many method references: 70561; max is 65536. You may try using --multi-dex option.

Ok, I found the multiDexEnabled property and added

multiDexEnabled true

in the

defaultConfig

Also I made my application extend

MultiDexApplication

But it did not change anything, I still get

Execution failed for task ':logic:dexDebugTest'. trouble writing output: Too many method references: 70561; max is 65536. You may try using --multi-dex option.

And it even explicitly shows me the dx comand without --multi-dex parameter

sdk/build-tools/21.1.1/dx --dex --output /build/intermediates/dex/test/debug --input-list=build/intermediates/tmp/dex/test/debug/libraryList.txt

Answer1:

try adding this to your build.gradle

android{ ... afterEvaluate { tasks.matching { it.name.startsWith('dex') }.each { dx -> if (dx.additionalParameters == null) { dx.additionalParameters = ['--multi-dex'] } else { dx.additionalParameters += '--multi-dex' } } } ... }

Recommend

  • python, pyenv and recompiling to handle a 64bit issue?
  • Error installing mod_wsgi 3.2
  • Last digit of power list
  • Active Directory - check if password never expires?
  • How to solve this java.nio.BufferOverflowException error?
  • How can I compile a java file on my Android Emulator?
  • Multiple dex files define Lcom/google/android/gms/common/internal/zzag
  • How to overcome jar dependency hell when multiple modules use the same jar?
  • draw pie chart using iOS quartz 2D
  • Pointer vs Reference difference when passing Eigen objects as arguments
  • LNK1104: cannot open file 'kernel32.lib'
  • Slicing an SPA into several components and use AngularJS
  • Can my PDF ping my server when it is opened?
  • Pycharm: Marking a folder as 'sources root' is not recursive for subfolders
  • Build Successful but not running on simulator
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • I18n locale disregarding fallbacks
  • RxJava debounce by arbitrary value
  • Sequential (transactional) API calls in angular 4 with state management
  • Spring Cloud Microservice Architecture Confusion
  • D3 get axis values on zoom event
  • WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?
  • Connect .sks to skscene.h
  • C: Incompatible pointer type initializing
  • How do I access an unhandled exception in an MVC Error view?
  • iOS: Detect app start via notification press
  • Google Custom Search with transparent background
  • Spring Data JPA custom method causing PropertyReferenceException
  • C# - Serializing and deserializing static member
  • Sending data from AppleScript to FileMaker records
  • Trying to switch camera back to front but getting exception
  • vba code to select only visible cells in specific column except heading
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • How to get next/previous record number?
  • How to include full .NET prerequisite for Wix Burn installer
  • Free memory of cv::Mat loaded using FileStorage API
  • Angular 2 constructor injection vs direct access
  • Is it possible to post an object from jquery to bottle.py?
  • Programmatically clearing map cache
  • To Get the radio button value in ruby on rails