For the last few days I've been unable to run cordova run android
(or rather, ionic run android
) to test my Ionic app on my native device. When I run the command, I get the usual metric ton of output, along with 100% CPU usage from several Java Runtime processes, then the build finally fails with the stated in the title. The console shows this (truncated, as there's a ton of output):
:compileDebugNdk UP-TO-DATE :compileDebugSources
:transformClassesWithDexForDebug UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:484) at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:261) at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:473) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:161) at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) FAILED
BUILD FAILED
Total time: 1 mins 40.116 secs
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334) at com.android.dx.command.dexer.Main.run(Main.java:277) at com.android.dx.command.dexer.Main.main(Main.java:245) at com.android.dx.command.Main.main(Main.java:106)
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task :transformClassesWithDexForDebug.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:
Process 'command 'C:\Program Files\Java\jdk1.8.0_73\bin\java.exe'' finished with non-zero exit value 2
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Error: Error code 1 for command: cmd with args: /s,/c,"E:\Documents\GitHub\app.auroras.live\platforms\android\gradlew cdvBuildDebug -b E:\Documents\GitHub\app.auroras.live\platforms\android\build.gradle -PcdvBuildArch=arm -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"
I just went and updated any necessary tools and libraries in the Android SDK, then I removed and re-added the Android platform (cordova platform add android
), making sure to check that all the relevant platform files were gone, and the project still fails to build.
EDIT: I also ran cordova clean
, but that didn't work. It looks like the Google Play Services library is causing my app to hit the 64,000 method limit, but other than manually tweaking my gradle file (which I'm not au fait with yet), I'm not sure how I can shrink that down
EDIT 2: I tried tweaking my build.gradle file to remove the reference to "com.google.android.gms:play-services:+" (which I think is pushing my app above the 65535 method limit) but it just keeps coming back.
I also tried a build-extras.gradle to remove the dependency, but got another error. Ideally I'd like an answer that doesn't require constant re-working every time I want to build my app, but at this stage I'm keen for pretty much anything.
I did recently upgrade cordova, ionic and bower (using npm install -g cordova ionic bower
after something went screwy with my %PATH% variable on Windows, but I wouldn't imagine that would break anything.
I'm running Windows 10, x64. java -version
reports:
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
Any suggestions?