Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Error building app #136

Closed
caipigott opened this issue Sep 15, 2015 · 7 comments
Closed

Error building app #136

caipigott opened this issue Sep 15, 2015 · 7 comments
Milestone

Comments

@caipigott
Copy link

Hi,

after adding the latest version of the push plugin my app fails on build.
My Versions:
cordova 5.3.1
Installed platforms: android 4.1.1

To add the plugin i used:
cordova plugin add https://github.com/phonegap/phonegap-plugin-push.git#1.2.3 (found this #1.2.3 on a closed issue)

The build fails with this error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotat
ion/AnimRes;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:50
2)
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)

:dexDebug FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':dexDebug'.

Any idea what can be the problem?

Thanks for your help,
Caipigott

@fredgalvao
Copy link
Collaborator

This is a duplicate of the issue described at #51

Details

The problem is that versions <= 1.2.3 still use the android-support-v13.jar instead of using the gradle dependency, and it was known to cause issues whenever you had any other plugin or custom code that had another dependency on android-support, which would cause that "multiple dex" issue. It's been solved recently on master (6b5bebb), but a stable version hasn't been released yet with the fix, so you might wanna try installing directly from the git url pointing to the master branch. Beware though that it's considered unstable code.
cordova plugin rm phonegap-plugin-push
cordova plugin add https://github.com/phonegap/phonegap-plugin-push.git

Workaround

Another way to solve it is installing whichever version you have or can, stable or not, and then you do:
1- Delete the android-support-*.jar from /platforms/android/lib/
2- Create a file called build-extras.gradle at /platforms/android/ (it should be side-by-side with build.gradle) and give it this content:

dependencies {
    compile "com.android.support:support-v13:23+"
}

The project should then compile successfully (this is how I solved it before the gradle fix), but your mileage may vary.

@macdonst
Copy link
Member

I've already made the switch to gradle build in master and I will be releasing a 1.3.0 later this week.

@caipigott
Copy link
Author

Hi,

thanks a lot for your help.
I guess i will wait for the new release as it will come soon anyway.

Have a nice day,
Caipigott

@caipigott
Copy link
Author

HI,

yesterday i updated to Version 1.3.0 and it works perfect!

Thanks for great work.

Greetings,
Caipigott

@EvHaus
Copy link

EvHaus commented Nov 8, 2015

I am having the same error:

Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:
Unknown source file : com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
Unknown source file :   at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
Unknown source file :   at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
Unknown source file :   at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
Unknown source file :   at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
Unknown source file :   at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
Unknown source file :   at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
Unknown source file :   at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
Unknown source file :   at com.android.dx.command.dexer.Main.run(Main.java:277)
Unknown source file :   at com.android.dx.command.dexer.Main.main(Main.java:245)
Unknown source file :   at com.android.dx.command.Main.main(Main.java:106)

:dexDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_60\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.

BUILD FAILED

However, I am running version 1.4.2 of the plugin (which is the latest).

Any other suggestions on how to fix this?

@fredgalvao
Copy link
Collaborator

@globexdesigns Some other plugin on your application is including a .jar of android-support-v4 somewhere, and that's conflicting with what gradle dependencies generate.

[if you're on unix] Please run this at the root of your cordova project to try and find it:
find ./** -name '*.jar'

There's 2 possible outcomes of that:

  1. A .jar file is found at the plugins/ AND platforms/android/ folder, in which case you need to contact the author of said plugin so that he can update it to use gradle dependencies instead of including the jar directly.
  2. A .jar file is found at the platforms/android/lib ONLY, and that indicates that a leftover of another plugin or an older version of phonegap-plugin-push is present, and you should simply delete it from that folder.

@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants