简体   繁体   中英

Multidex in IntelliJ IDEA with Maven

I've got a Maven project which currently is not an IntelliJ IDEA project. I imported it via File -> Open Project and then choosing the root pom.xml.

Everything seems to be imported fine, all modules are there and the Android modules are configured correctly.

I then added a run configuration for the Android module I want to execute.

When building I get the following error:

Error:Android Dex: [at.demoproject] Unable to execute DX
Error:Android Dex: [at.demoproject] com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
Error:Android Dex: [at.demoproject] at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:484)
Error:Android Dex: [at.demoproject] at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:261)
Error:Android Dex: [at.demoproject] at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:473)
Error:Android Dex: [at.demoproject] at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:161)
Error:Android Dex: [at.demoproject] at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
Error:Android Dex: [at.demoproject] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
Error:Android Dex: [at.demoproject] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
Error:Android Dex: [at.demoproject] at com.android.dx.command.dexer.Main.run(Main.java:277)
Error:Android Dex: [at.demoproject] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:Android Dex: [at.demoproject] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Error:Android Dex: [at.demoproject] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Error:Android Dex: [at.demoproject] at java.lang.reflect.Method.invoke(Method.java:606)
Error:Android Dex: [at.demoproject] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:188)
Error:Android Dex: [at.demoproject] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:336)

But multidex is already set up and working fine with android-maven-plugin. (When building directly in the command line with Maven) I suspect that IntelliJ isn't using android-maven-plugin, but how do i tell it to use multidex then? Also, converting the project to Gradle is no option currently.

Ok, I figured it out myself.

Instead of letting IntelliJ built it, you can use Maven. Just open the Run/Debug configuration and remove "Make" in the "Before launch" list. Then add "Run Maven Goal" and enter the goals to run, in my case "clean install".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM